当前位置:网站首页>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
.
边栏推荐
- What is the implementation principle of Go iota keyword and enumeration type
- 广汽埃安“弹匣电池”,四大核心技术,出行安全保障
- 小贝拉机器人是朋友_普渡科技召开新品发布会,新一代送餐机器人“贝拉”温暖登场...
- 2022年MySQL最新面试题
- B005 - STC8 based single chip microcomputer intelligent street light control system
- Leetcode73. 矩阵置零
- CodeTON Round 2 (Div. 1 + Div. 2, Rated, Prizes!) Solution
- 创造建材数字转型新视界,中建材如何多边赋能集团业务快速发展
- 使用设备树时对应的驱动编程
- Leetcode74. 搜索二维矩阵
猜你喜欢
随机推荐
golang json returns null
B002 - 基于嵌入式的老人定位追踪监测仪
【Day_10 0428】密码强度等级
想随时、随地、随心使用数据库的朋友们,全体注意!
QLineEdit学习与使用
QT常用全局宏定义
消息模板占位符的使用
AIOps智能运维的领跑者擎创科技正式入驻InfoQ 写作社区!
Leetcode71. 简化路径
MySQL 45 讲 | 09 普通索引和唯一索引,应该怎么选择?
解决MySQL插入不了中文数据问题
BITS Pilani|SAC-AP:基于 Soft Actor Critic 的深度强化学习用于警报优先级
【Day_08 0426】两种排序方法
【Translation】OpenMetrics cultivated by CNCF becomes an incubation project
Stop using MySQL online DDL
国标GB28181协议EasyGBS平台兼容老版本收流端口的功能实现
QT_QThread线程
C语言理论--笔试面试基础稳固
三种方案解决:npm WARN config global --global, --local are deprecated. Use --location=global instead.
C language theory--a solid foundation for the written test and interview