Skip to content

Instantly share code, notes, and snippets.

@kirsteins
Created August 15, 2016 10:41
Show Gist options
  • Save kirsteins/b6c53d54c85297acf43d90601fd86989 to your computer and use it in GitHub Desktop.
Save kirsteins/b6c53d54c85297acf43d90601fd86989 to your computer and use it in GitHub Desktop.
/// Get the top most view controller in presentation chain
func topPresentedController() -> UIViewController? {
var topPresentedController = rootViewController
while let nextTopPresentedController = topPresentedController?.presentedViewController {
topPresentedController = nextTopPresentedController
}
return topPresentedController
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment