Skip to content

Instantly share code, notes, and snippets.

@chriswebb09
Created May 11, 2017 08:55
Show Gist options
  • Save chriswebb09/1332ee45d54bf1b02b3fa84efd6434e7 to your computer and use it in GitHub Desktop.
Save chriswebb09/1332ee45d54bf1b02b3fa84efd6434e7 to your computer and use it in GitHub Desktop.
class ViewTraverser {
private func traverseSuperViews(view: UIView) -> [Int : UIView] {
var views: [Int: UIView] = [:]
var inputView: UIView? = view
while inputView != nil {
guard let tag = inputView?.tag, let view = inputView else { continue }
views[tag] = view
inputView = view.superview
}
return views
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment