zoukankan      html  css  js  c++  java
  • 新浪微博客户端(4)-设置导航栏主题

    为了使整个项目的NavigationBar 上的UIBarButtonItem的颜色,字体大小一致,需要设置导航栏主题。

    由于项目使用的是自定义的DJNavigationController,而又要保证只设置一次,所以将设置主题的代码写在DJNavigationController.m文件中的initialize方法中。

    DJNavigationController.m

    #import "DJNavigationController.h"
    
    @implementation DJNavigationController
    
    
    
    + (void)initialize {
    
        UIBarButtonItem *btnItem = [UIBarButtonItem appearance];
        
        // 设置当前item可用状态
        NSMutableDictionary *normalAttr = [NSMutableDictionary dictionary];
        // 设置前景色
        normalAttr[NSForegroundColorAttributeName] = [UIColor orangeColor];
        // 设置当前字体大小
        normalAttr[NSFontAttributeName] = [UIFont systemFontOfSize:14];
        [btnItem setTitleTextAttributes:normalAttr forState:UIControlStateNormal];
        
        
        // 设置当前item不可用状态
        NSMutableDictionary *disableAttr = [NSMutableDictionary dictionary];
        disableAttr[NSForegroundColorAttributeName] = [UIColor grayColor];
        disableAttr[NSFontAttributeName] = [UIFont systemFontOfSize:14];
        [btnItem setTitleTextAttributes:disableAttr forState:UIControlStateDisabled];
        
    }

    最终效果:

  • 相关阅读:
    py基础之模块与包
    py装饰器,生成器,迭代器
    py函数式编程
    py基础之列表生成式
    算法基础之递归算法
    Py基础之函数
    py基础之无序列表
    py基础之数据类型及基本语法
    jsp报错问题汇总
    mysql问题汇总
  • 原文地址:https://www.cnblogs.com/yongdaimi/p/5962132.html
Copyright © 2011-2022 走看看