据说是看view的层级关系的,求大神教教如何看的

- (void)show:(UIView *)view level:(int)le
{
    for (int i=0; i<le; i++) {
        printf("   ");
    }
    printf("[%d]:%s\n",le,[[view  description] UTF8String]);
    
    for (UIView *temp in view.subviews) {
        [self show:temp level:le+1];
    }
}
- (void)showAllSubviews
{
    printf("\n");
    [self show:self level:0];
}

- (void)showViewAndLayer:(UIView *)view level:(int)le
{
    for (int i=0; i<le; i++) {
        printf("   ");
    }
    printf("[%d]:%s\n",le,[[view  description] UTF8String]);
    
    for (int i=0; i<le; i++) {
        printf("   ");
    }
    printf("{");
    printf("\n");
    [self showLayer:view.layer level:le];
    for (int i=0; i<le; i++) {
        printf("   ");
    }
    printf("}\n");
    
    for (UIView *temp in view.subviews) {
        [self showViewAndLayer:temp level:le+1];
    }
}
- (void)showLayer:(CALayer *)layer level:(int)le
{
    for (int i=0; i<le; i++) {
        printf("   ");
    }
    printf("(%d):%s\n",le,[[layer  description] UTF8String]);
    
    for (CALayer *temp in layer.sublayers) {
        [self showLayer:temp level:le+1];
    }
    
}
查看回复