iOS类中的属性设置背景色(统一)

     unsigned int count;
        objc_property_t *properties = class_copyPropertyList([self class], &count);
        for (int i = 0; i < count; i++) {
            objc_property_t property = properties[i];
            NSString *propertyName = [NSString stringWithCString:property_getName(property) encoding:NSUTF8StringEncoding];
            UIView *view = [self valueForKey:propertyName];
            if ([view isKindOfClass:[UIView class]]) {
                view.backgroundColor = [UIColor cyanColor];
            }
        }
        free(properties);

这在调试的时候是非常有用的,不必每一个uiview都设置一次背景颜色。。。

posted @ 2016-06-13 15:08  向日夏  阅读(427)  评论(0编辑  收藏  举报