Created
August 11, 2018 14:02
-
-
Save kingiol/40edb046ca3c7aec4d3652641a9338ce to your computer and use it in GitHub Desktop.
打印UIView的所有子节点结构
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
func hierarchyOfView(_ view: UIView, level: Int = 1) { | |
let subviews = view.subviews | |
if subviews.isEmpty { return } | |
for subview in subviews { | |
var blank = "" | |
for _ in 1..<level { | |
blank += "-" | |
} | |
print(blank + "\(level): " + subview.self) | |
hierarchyOfView(subview, level: level + 1) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment