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]];
}
}
@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