1.设置当前viewcontroller 的所有UILable 的背景颜色
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self setAllLabelColor:[UIColor redColor] rootView:self.view];
}
-(void)setAllLabelColor:(UIColor*)color rootView:(UIView*)view
{
if ([view isMemberOfClass:[UILabel class]]) {
UILabel * label = (UILabel*)view;
[label setBackgroundColor:color];
}else if(view.subviews.count > 0){
for (UIView * subview in view.subviews) {
[self setAllLabelColor:color rootView:subview];
}
}
}