Created
August 10, 2016 21:25
-
-
Save AnselmeKotchap/fdb5c96edeed383559aee5a0935ed502 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIViewController { | |
public var isVisible: Bool { | |
if isViewLoaded() { | |
return view.window != nil | |
} | |
return false | |
} | |
public var isTopViewController: Bool { | |
if self.navigationController != nil { | |
return self.navigationController?.visibleViewController === self | |
} else if self.tabBarController != nil { | |
return self.tabBarController?.selectedViewController == self && self.presentedViewController == nil | |
} else { | |
return self.presentedViewController == nil && self.isVisible | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment