当前位置:网站首页>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
.
边栏推荐
- COS 用户实践征文
- Go iota关键字与枚举类型实现原理是什么
- 2022年SQL大厂高频实战面试题(详细解析)
- 小贝拉机器人是朋友_普渡科技召开新品发布会,新一代送餐机器人“贝拉”温暖登场...
- golang json returns null
- University of California | Inverse Reinforcement Learning from Different Third-Person Videos via Graph Abstraction
- 使用设备树时对应的驱动编程
- B011 - 51-based multifunctional fingerprint smart lock
- 浅谈游戏音效测试点
- opencv基本的图像处理
猜你喜欢
以消费场景为驱动的CMDB要怎么建?
B011 - 51-based multifunctional fingerprint smart lock
XAML WPF项目groupBox控件
Leetcode73. Matrix Zeroing
MySQL 45 讲 | 09 普通索引和唯一索引,应该怎么选择?
How to solve the dynamic binding of el-form-item prop attribute does not take effect
Leetcode72. 编辑距离
B001 - Intelligent ecological fish tank based on STM32
亚马逊云科技Build On2022技能提升计划第二季——揭秘出海爆款新物种背后的黑科技
QT基础功能,信号、槽
随机推荐
基于BiGRU和GAN的数据生成方法
三种方案解决:npm WARN config global --global, --local are deprecated. Use --location=global instead.
Go iota关键字与枚举类型实现原理是什么
2022年SQL经典面试题总结(带解析)
Leetcode72. Edit Distance
Leetcode74. 搜索二维矩阵
【Translation】OpenMetrics cultivated by CNCF becomes an incubation project
QPalette调色板、框架色彩填充
SQL的索引详细介绍
以消费场景为驱动的CMDB要怎么建?
力扣每日一题-第45天-697. 数组的度
gtk显示4通道rgba图像
What is the implementation principle of Go iota keyword and enumeration type
COS 用户实践征文
B011 - 基于51的多功能指纹智能锁
想随时、随地、随心使用数据库的朋友们,全体注意!
LeaRun.net快速开发动态表单
typora操作手册
加州大学|通过图抽象从不同的第三人称视频中进行逆强化学习
WinRAR | 将多个安装程序生成一个安装程序