Created
October 3, 2024 06:31
-
-
Save ha1f/562954fd8a945c7166a7dfb0828b5f0c to your computer and use it in GitHub Desktop.
This file contains 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 { | |
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