iOS 中控件的appearance 属性的应用

   //通过appreaance 统一设置UITabBarItem的属性
    //后面带有 UI_APPEARANCE_SELECTOR 的方法 都可以通过appearance对象来统一创建
    [UINavigationBar appearance];

    NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
    attrs[NSFontAttributeName] = [UIFont systemFontOfSize:12];
    attrs[NSForegroundColorAttributeName] = [UIColor grayColor];
    
    NSMutableDictionary *selectedAttrs = [NSMutableDictionary dictionary];
    selectedAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:12];
    selectedAttrs[NSForegroundColorAttributeName] = [UIColor darkGrayColor];
    
//统一创建  [UITabBarItem appearance];
    UITabBarItem *item = [UITabBarItem appearance];
    [item setTitleTextAttributes:attrs forState:UIControlStateNormal];
    [item setTitleTextAttributes:selectedAttrs forState:UIControlStateSelected];
原文地址:https://www.cnblogs.com/arenouba/p/5428673.html