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];
        
    }

    最终效果:

  • 相关阅读:
    SQL Server创建表
    SQL Server创建数据库
    SQL Server创建索引
    SQL Server创建视图
    SQL Server创建存储过程
    SQL Server创建触发器
    Unity3D与VS2008结合,加快Unity3D C#开发!
    c#哈希表的用法
    长沙做网站公司解密如何编写高效率的SQL语句
    高效SQL语句必杀技
  • 原文地址:https://www.cnblogs.com/yongdaimi/p/5962132.html
Copyright © 2011-2022 走看看