Skip to content

Instantly share code, notes, and snippets.

@efremidze
Last active March 12, 2017 01:08
Show Gist options
  • Save efremidze/05e958e7a7cc3787345902e920e869a7 to your computer and use it in GitHub Desktop.
Save efremidze/05e958e7a7cc3787345902e920e869a7 to your computer and use it in GitHub Desktop.
find superview of given type
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