当前位置:网站首页>新浪微博客户端(4)-设置导航栏主题
新浪微博客户端(4)-设置导航栏主题
2022-07-19 14:10:00 【全栈程序员站长】
大家好,又见面了,我是全栈君。
为了使整个项目的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];
}
最终效果:
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/108839.html原文链接:https://javaforall.cn
边栏推荐
- Programmer's health quench prevention guide 6:[Science] exercise
- GC 机制简介
- Development of video splicing technology
- Fuzzy comprehensive evaluation method
- 51单片机按键控制LED灯状态
- En savoir plus sur le pool de Threads simultanés juc (VIII)
- 解决报错SyntaxError:Unexpected end of JSON input
- 中创沙龙 | 数字藏品“破圈”出击
- 如何打造3D立体世界?跟随图片一同探寻
- [FAQ] access the HMS core push service, and the server sends messages. Cause analysis and solutions of common error codes
猜你喜欢
Preparation Notes: opencv learning: color recognition
模糊综合评价法
Introduction to several scenarios involving programming operation of Excel in SAP implementation project
Using GPU to discover human brain connections, large-scale GPU achieves a 100 fold acceleration
【性能优化】MySQL性能优化之存储引擎调优
网易云信音视频能力中台,全速助力银行业数字化转型升级
Vulnhub target: hacker kid_ 1.0.1
备赛笔记:Opencv学习:颜色识别
【毕业设计】基于微服务框架的电影院订票管理系统
统计信息简介
随机推荐
How to create a 3D world? Explore with pictures
解决报错SyntaxError:Unexpected end of JSON input
泰山OFFICE技术讲座:有哪些关于高度的概念
Plunger pump Parker pvp23363r26a121
区间合并[关键问题+解决方案]
测试岗位面试常见算法题集锦
首个X光下的小样本检测基准和弱特征增强网络,北航、讯飞新研究入选ACM MM 2022
In depth understanding of JUC concurrent (VIII) thread pool
Simple solution of CSV Chinese garbled code when opening CSV with Excel
【OpenCV 例程200篇】237. 基于主成分提取的方向校正(OpenCV)
Data science and Computational Intelligence: connotation, paradigm and opportunity
硅谷课堂第十二课-公众号点播课程和直播管理模块
The first small sample detection benchmark and weak feature enhancement network under X-ray, and the new research of Beihang and iFLYTEK was selected into ACM mm 2022
51单片机按键控制LED灯状态
In the first half of the year, Guangdong's exports increased by 7.3%, and high-tech products accelerated "going to sea"
硅谷课堂第十三课-直播管理模块
Taishan Office Technology Lecture: what are the concepts of height
[FAQ] access the HMS core push service, and the server sends messages. Cause analysis and solutions of common error codes
测试--基础知识篇
硅谷课堂第十一课-公众号消息和微信授权