Skip to content

Commit

Permalink
Merge pull request #60 from devxoul/bring-window-to-top
Browse files Browse the repository at this point in the history
Bring JLToastWindow to top when another window is being shown.
  • Loading branch information
devxoul committed Dec 21, 2015
2 parents 446fc8a + 69ae2c8 commit 6380eac
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 6380eac

Please sign in to comment.