Created
July 26, 2020 00:45
-
-
Save Geri-Borbas/e915482b16020f4509671c44600036ea to your computer and use it in GitHub Desktop.
Print recursive `UIKit` view hierarchy information.
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 printViewHierarchyInformation(_ level: Int = 0) { | |
| printViewInformation(level) | |
| self.subviews.forEach { $0.printViewHierarchyInformation(level + 1) } | |
| } | |
| func printViewInformation(_ level: Int) { | |
| let leadingWhitespace = String(repeating: " ", count: level) | |
| let className = "\(Self.self)" | |
| let superclassName = "\(self.superclass!)" | |
| print("\(leadingWhitespace)\(className): \(superclassName)") | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment