Skip to content

Instantly share code, notes, and snippets.

@AnselmeKotchap
Created August 10, 2016 21:25
Show Gist options
  • Save AnselmeKotchap/fdb5c96edeed383559aee5a0935ed502 to your computer and use it in GitHub Desktop.
Save AnselmeKotchap/fdb5c96edeed383559aee5a0935ed502 to your computer and use it in GitHub Desktop.
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