Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static var topMostViewController: UIViewController {
- var viewController: UIViewController = (UIApplication.shared.keyWindow?.rootViewController)!
- while (viewController.presentedViewController != nil){
- viewController = viewController.presentedViewController!
- }
- return viewController
- }
- static var currentViewController: UIViewController? {
- if let tabBarController = UIViewController.topMostViewController as? UITabBarController {
- if let navigationController = tabBarController.selectedViewController as? UINavigationController {
- return navigationController.viewControllers.first
- } else {
- return tabBarController.selectedViewController
- }
- } else if let navigationController = UIViewController.topMostViewController as? UINavigationController {
- return navigationController.viewControllers.first
- } else {
- return UIViewController.topMostViewController
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement