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

    最终效果:

  • 相关阅读:
    mysql逻辑架构
    delete与truncate的区别
    mycat
    mycat
    MyCat数据库中间件
    mysql主从复制
    docker学习笔记之快速安装
    linux学习笔记之CentOS7系统快速安装
    Redis学习笔记
    双绞线的种类与型号
  • 原文地址:https://www.cnblogs.com/yongdaimi/p/5962132.html
Copyright © 2011-2022 走看看