find Top Most View Controller
private fun findTopMostViewController(rootViewController: UIViewController?): UIViewController?(source)
Recursively traverses the view controller hierarchy to find the visible controller.
It handles:
Presented View Controllers (Modals)
UINavigationController (Visible Child)
UITabBarController (Selected Child)
Return
The top-most visible UIViewController.
Parameters
root View Controller
The starting point for the search, typically the key window's root.