标签:视图 lan 获取 elf uiview evel eve gets 直接
// 递归获取子视图
- (void)getSub:(UIView *)view andLevel:(int)level {
NSArray *subviews = [view subviews];
// 如果没有子视图就直接返回
if ([subviews count] == 0) return;
for (UIView *subview in subviews) {
// 根据层级决定前面空格个数,来缩进显示
NSString *blank = @"";
for (int i = 1; i < level; i++) {
blank = [NSString stringWithFormat:@" %@", blank];
}
// 打印子视图类名
NSLog(@"%@%d: %@", blank, level, subview.class);
// 递归获取此视图的子视图
[self getSub:subview andLevel:(level+1)];
}
}
标签:视图 lan 获取 elf uiview evel eve gets 直接
原文地址:https://www.cnblogs.com/linusflow/p/8810200.html