Created
October 14, 2016 02:58
-
-
Save Coderian/424c83dbe6eeb1752c63686356353e1b to your computer and use it in GitHub Desktop.
iOS UIViewの階層構造をprintする extension by Swift 3.0 ref: http://qiita.com/gi0_0iv/items/159fcdb19074ee66ca38
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
<UILayoutContainerView: ... | |
<UINavigationTransitionVIew: ... | |
: |
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
import Funcation | |
import UIKit | |
extension UIWindow { | |
func printSubviewHierarchy() { | |
var tabs:String = "" | |
printSubviews(subviews: self.subviews, tabs: &tabs) | |
} | |
private func printSubviews(subviews: [UIView], tabs:inout String) { | |
tabs += " " | |
for view in subviews { | |
print(tabs + "\(view.self)") | |
printSubviews(subviews: view.subviews, tabs: &tabs) | |
} | |
tabs.remove(at: tabs.index(before: tabs.endIndex)) | |
} | |
} |
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
@IBAction func tapped(_ sender: UIButton){ | |
self.view.window?.printSubviewHierarchy() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment