iOS使用 UIAppearance 做控件的默认设置

2018-09-25  本文已影响7人  闻人歌
@property (nonatomic) CGFloat avatarSize UI_APPEARANCE_SELECTOR; //default 30;
+ (void)initialize
{
    // UIAppearance Proxy Defaults
    MyTbCell *cell = [self appearance];
    cell.avatarSize = 30; 
}
- (void)setAvatarSize:(CGFloat)avatarSize
{
    _avatarSize = avatarSize; 
    NSLog(@"%lf",_avatarSize);
}

同样的,在设置导航栏的时候:

+ (void)initialize
{
     // 获取特定类的所有导航条
  UINavigationBar *navigationBar = [UINavigationBar appearanceWhenContainedIn:self, nil]; 
  navigationBar.tintColor = [UIColor whiteColor]; 
}
上一篇 下一篇

猜你喜欢

热点阅读