当前位置:网站首页>Summer vacation second week wrap-up blog
Summer vacation second week wrap-up blog
2022-08-01 18:10:00 【Ouhai sword】
UINavigationController Background color design problem
- 升级到 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;
button select settings
创建按钮时,Set the styles for both the normal state and the selected state at the same time.
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];
// Set the normal status picture
[button setImage:icon01 forState:UIControlStateNormal];
// 设置选中状态图片
[button setImage:icon02 forState:UIControlStateSelected];
// 添加事件
[button addTarget:self action:@selector(pressButton:) forControlEvents:UIControlEventTouchUpInside];
Then add the code to toggle the selected state in the click event.
- (void) pressButton:(UIButton*)button {
// 切换选中状态
button.selected = !button.selected;
}
UITabBarItemImage setting problem
When I set it as followsUITabBarItemWhen you encounter pictures,图片无法显示问题(It shows up as a large block of color).
UITabBarItem* TabBarItem = [[UITabBarItem alloc] initWithTitle:nil image:[UIImage imageNamed:@"56.png"] selectedImage:[UIImage imageNamed:@"firstbutton_pressed.png"]];
navigationController.tabBarItem = TabBarItem;
示:
This can be solved by changing the rendering mode of the image:
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
.
边栏推荐
猜你喜欢
随机推荐
面经汇总-社招-6年
突破性能天花板!亚信数据库支撑 10 多亿用户,峰值每秒百万交易
md5sum源码 可多平台编译
国标GB28181协议EasyGBS平台兼容老版本收流端口的功能实现
2022年MySQL最新面试题
Leetcode72. 编辑距离
以消费场景为驱动的CMDB要怎么建?
频域分析实践介绍
golang json 返回空值
CodeTON Round 2 (Div. 1 + Div. 2, Rated, Prizes!) 题解
中信证券是国内十大券商吗?怎么开户安全?
我在启牛开户安全吗?谁能告诉我开不靠谱?
RecSys'22|CARCA: Cross-Attention-Aware Context and Attribute Recommendations
直播系统聊天技术(八):vivo直播系统中IM消息模块的架构实践
Topology Parts Disassembly 3D Visualization Solution
tooltip control
史上最全的Redis基础+进阶项目实战总结笔记
B005 – 基于STC8的单片机智能路灯控制系统
bat 批示处理详解-2
MySQL 45 讲 | 09 普通索引和唯一索引,应该怎么选择?