Last active
March 12, 2017 01:08
-
-
Save efremidze/05e958e7a7cc3787345902e920e869a7 to your computer and use it in GitHub Desktop.
find superview of given type
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIView { | |
func superview<T>(of type: T.Type) -> T? { | |
return superview as? T ?? superview.flatMap { $0.superview(of: T.self) } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment