Skip to content

Instantly share code, notes, and snippets.

@dmytro-anokhin
Last active January 17, 2021 13:41
Show Gist options
  • Save dmytro-anokhin/fb1d0971e406c0b2221a28cc2102ef22 to your computer and use it in GitHub Desktop.
Save dmytro-anokhin/fb1d0971e406c0b2221a28cc2102ef22 to your computer and use it in GitHub Desktop.
extension UIWindow {
/// Print the app's key window hierarchy.
class func printKeyWindowHierarchy() {
UIApplication.shared.keyWindow?.printHierarchy()
}
/// Prints the window's view hierarchy.
func printHierarchy() {
traverseHierarchy { responder, level in
print(String(repeating: " ", count: level * 2) + String(describing: responder))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment