I am creating a title bar for my iOS application and I am making this inside a UIView. The only issue I am having is with the \"home button\". When the home button is presse
Here's a more idiomatic Swift 3 version of Shamsudheen's answer:
extension UIApplication {
static func topViewController() -> UIViewController? {
guard var top = shared.keyWindow?.rootViewController else {
return nil
}
while let next = top.presentedViewController {
top = next
}
return top
}
}
Then you can just call:
UIApplication.topViewController()?.present(...)