Skip to content

Commit

Permalink
Bring JLToastWindow to top when another window is being shown.
Browse files Browse the repository at this point in the history
  • Loading branch information
devxoul committed Dec 15, 2015
1 parent 446fc8a commit 69ae2c8
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions JLToast/JLToastWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,25 @@ public class JLToastWindow: UIWindow {

public override init(frame: CGRect) {
super.init(frame: frame)
NSNotificationCenter.defaultCenter().addObserver(self,
selector: "bringWindowToTop:",
name: UIWindowDidBecomeVisibleNotification,
object: nil
)
}

required public init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

/// Bring JLToastWindow to top when another window is being shown.
func bringWindowToTop(notification: NSNotification) {
if !(notification.object is JLToastWindow) {
self.dynamicType.sharedWindow.hidden = true
self.dynamicType.sharedWindow.hidden = false
}
}

}


Expand Down

0 comments on commit 69ae2c8

Please sign in to comment.