Created
April 21, 2019 15:58
-
-
Save pavel-sazonov/9fe5547a10e7e98a891de5050a296faa to your computer and use it in GitHub Desktop.
extension to define contents of Navigation or Tabbar Controller
This file contains 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 { | |
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