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都设置一次背景颜色。。。