Is there a built-in way to get from a UIView to its UIViewController? I know you can get from UIViewController to its UIView
UIView
UIViewController
Swiftier solution
extension UIView { var parentViewController: UIViewController? { for responder in sequence(first: self, next: { $0.next }) { if let viewController = responder as? UIViewController { return viewController } } return nil } }