利用Apperance协议定义View的全局外观
假设要定义一个全局的bkColor用于背景颜色
1.@property(nonatomic,strong)UIColor *bkColor UI_APPEARANCE_SELECTOR;
2.在下面方法中定义默认的背景颜色bkColr = redcolor;
+(void)initialize{
[CustomView appearance].bkColor = [UIColor redColor];
}
3.在set方法里面设置backgroundColor;
- (void)setBkColor:(UIColor *)bkColor{
_bkColor = bkColor;
self.backgroundColor = bkColor;
}
4:在使用时就可以利用来设置view的某个全局的属性啦
[[CustomView appearance] setBkColor:[UIColor yellowColor]];