Skip to content

Instantly share code, notes, and snippets.

@Glideh
Last active May 25, 2022 02:36
Show Gist options
  • Save Glideh/325efa9b5f3a062b0065 to your computer and use it in GitHub Desktop.
Save Glideh/325efa9b5f3a062b0065 to your computer and use it in GitHub Desktop.
Lists views recursively with indentation for subviews
- (void)listSubviewsOfView:(UIView *)view {
[self listSubviewsOfView:(UIView *)view withPrefix:@""];
}
- (void)listSubviewsOfView:(UIView *)view withPrefix:(NSString *)prefix {
NSArray *subviews = [view subviews];
for (UIView *subview in subviews) {
NSLog(@"%@ %@ (%d %d; %d %d)", prefix, subview.class
, (int)subview.frame.origin.x
, (int)subview.frame.origin.y
, (int)subview.frame.size.width
, (int)subview.frame.size.height);
[self listSubviewsOfView:subview withPrefix:[NSString stringWithFormat:@"%@ ", prefix]];
}
}
@Glideh
Copy link
Author

Glideh commented Jun 17, 2014

Example of output:

_UILayoutGuide (0 0; 0 0)
_UILayoutGuide (0 0; 0 0)
DRPaginatedScrollView (0 0; 0 0)
    UIView (0 0; 0 0)
        UIView (0 0; 1024 768)
            UILabel (620 131; 109 21)
            UITableView (20 20; 320 460)
                UITableViewWrapperView (0 0; 320 460)
                UIImageView (0 456; 320 3)
                UIImageView (316 453; 3 7)
    UIView (0 0; 0 0)
        UIView (0 0; 1024 768)
            UILabel (159 157; 54 21)

@jvDev17
Copy link

jvDev17 commented Jan 28, 2015

Thanks @Glideh pretty sweet solution.. :)

@buting
Copy link

buting commented Mar 19, 2018

nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment