Skip to content

Instantly share code, notes, and snippets.

@ha1f
Created October 3, 2024 06:31
Show Gist options
  • Save ha1f/562954fd8a945c7166a7dfb0828b5f0c to your computer and use it in GitHub Desktop.
Save ha1f/562954fd8a945c7166a7dfb0828b5f0c to your computer and use it in GitHub Desktop.
extension UIView {
var recursiveSubviews: [UIView] {
subviews + subviews.flatMap(\.recursiveSubviews)
}
func printViewHierarchy(depth: Int = 0) {
for subview in subviews {
print("\(String(repeating: " ", count: depth))- \(String(describing: type(of: subview)))")
subview.printViewHierarchy(depth: depth + 1)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment