UIViewController

extension UIViewController
  • The current as in top most view controller.

    When determining the current view controller the following rules are applied recursively:

    • Start with the window’s root view controller
    • If a view controller is presented, select it
    • For a navigation controller, select the top view controller
    • For a tab bar controller, select the selected view controller
    • For a custom container view controller, select the last child view controller

    Example

    po UIViewController.current
    

    Declaration

    Swift

    @objc
    static var current: UIViewController { get }