Skip to content

Instantly share code, notes, and snippets.

@kingiol
Created August 11, 2018 14:02
Show Gist options
  • Save kingiol/40edb046ca3c7aec4d3652641a9338ce to your computer and use it in GitHub Desktop.
Save kingiol/40edb046ca3c7aec4d3652641a9338ce to your computer and use it in GitHub Desktop.
打印UIView的所有子节点结构
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