当前位置:网站首页>暑假第二周总结博客
暑假第二周总结博客
2022-08-01 18:03:00 【瓯海剑】
UINavigationController 背景颜色设计问题
- 升级到 Xcode 13 之前写的关于导航条 navigationBar 的颜色设置是直接调用 barTintColor 属性就可以实现。然而到了Xcode 13 颜色设置却失效了。
之前的代码:
// 设置不透明
self.navigationController.navigationBar.translucent = NO;
// 设置背景颜色
self.navigationController.navigationBar.tintColor = [UIColor redColor];
- 改之后
UINavigationBarAppearance* appearance = [[UINavigationBarAppearance alloc] init];
// 添加背景颜色
appearance.backgroundColor = [UIColor redColor];
appearance.shadowImage = [[UIImage alloc] init];
appearance.shadowColor = nil;
self.navigationController.navigationBar.standardAppearance = appearance;
self.navigationController.navigationBar.scrollEdgeAppearance = appearance;
按钮选中设置
创建按钮时,同时设置普通状态和选中状态的样式。
UIButton* button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = CGRectMake(100, 300, 200, 200);
button.selected = NO;
// 提取图片
UIImage* icon01 = [[UIImage imageNamed:@"btn01.jpeg"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
UIImage* icon02 = [[UIImage imageNamed:@"btn02.jpeg"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
// 设置普通状态图片
[button setImage:icon01 forState:UIControlStateNormal];
// 设置选中状态图片
[button setImage:icon02 forState:UIControlStateSelected];
// 添加事件
[button addTarget:self action:@selector(pressButton:) forControlEvents:UIControlEventTouchUpInside];
再点击事件中添加切换选中状态的代码。
- (void) pressButton:(UIButton*)button {
// 切换选中状态
button.selected = !button.selected;
}
UITabBarItem图片设置问题
当我用如下方法设置UITabBarItem图片时会遇到,图片无法显示问题(显示出来是一大块色块)。
UITabBarItem* TabBarItem = [[UITabBarItem alloc] initWithTitle:nil image:[UIImage imageNamed:@"56.png"] selectedImage:[UIImage imageNamed:@"firstbutton_pressed.png"]];
navigationController.tabBarItem = TabBarItem;
示:
这是我们改变图片的渲染模式就可以解决:
UITabBarItem* TabBarItem = [[UITabBarItem alloc] initWithTitle:nil image:[[UIImage imageNamed:@"56.png"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"firstbutton_pressed.png"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
navigationController.tabBarItem = TabBarItem;
改为 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal
。
边栏推荐
- How to build a CMDB driven by consumption scenarios?
- B002 - Embedded Elderly Positioning Tracking Monitor
- OpenCV安装、QT、VS配置项目设置
- 云原生全景图详解
- Leetcode73. Matrix Zeroing
- B002 - 基于嵌入式的老人定位追踪监测仪
- gtk显示4通道rgba图像
- 数字化采购管理系统开发:精细化采购业务流程管理,赋能企业实现“阳光采购”
- University of California | Inverse Reinforcement Learning from Different Third-Person Videos via Graph Abstraction
- What is the JVM runtime data area and the JMM memory model
猜你喜欢
Leetcode73. Matrix Zeroing
ExcelPatternTool: Excel表格-数据库互导工具
MySQL 45 Talk | 09 How to choose common index and unique index?
C language theory--a solid foundation for the written test and interview
数字化采购管理系统开发:精细化采购业务流程管理,赋能企业实现“阳光采购”
Leetcode75. Color Classification
Detailed explanation of DBPack SQL Tracing function and data encryption function
2022年MySQL最新面试题
XAML WPF项目groupBox控件
QPalette palette, frame color fill
随机推荐
使用设备树时对应的驱动编程
Leetcode71. 简化路径
频域分析实践介绍
LeaRun.net快速开发动态表单
小贝拉机器人是朋友_普渡科技召开新品发布会,新一代送餐机器人“贝拉”温暖登场...
How can become a good architect necessary skills: painting for all the people praise the system architecture diagram?What is the secret?Quick to open this article and have a look!.
食品安全 | 新鲜食品vs速食食品,哪一种是你的菜?
QT常用全局宏定义
SQL的索引详细介绍
opencv syntax Mat type summary
EpiSci|片上系统的深度强化学习:神话与现实
Tower Defense Shoreline User Agreement
行业沙龙第二期丨如何通过供应链数字化业务协同,赋能化工企业降本增效?
Leetcode73. Matrix Zeroing
粒子滤波 particle filter —从贝叶斯滤波到粒子滤波——Part-I(贝叶斯滤波)
How opencv implements image skew correction
基于ORB-SLAM2的改进代码
University of California | Inverse Reinforcement Learning from Different Third-Person Videos via Graph Abstraction
AIOps智能运维的领跑者擎创科技正式入驻InfoQ 写作社区!
What is the JVM runtime data area and the JMM memory model