Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pavel-sazonov/9fe5547a10e7e98a891de5050a296faa to your computer and use it in GitHub Desktop.
Save pavel-sazonov/9fe5547a10e7e98a891de5050a296faa to your computer and use it in GitHub Desktop.
extension to define contents of Navigation or Tabbar Controller
extension UIViewController {
var contents: UIViewController {
if let navcon = self as? UINavigationController {
return navcon.visibleViewController ?? self
} else if let tabcon = self as? UITabBarController {
return tabcon.selectedViewController ?? self
} else {
return self
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment