当前位置:网站首页>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.
边栏推荐
猜你喜欢
Detailed explanation of DBPack SQL Tracing function and data encryption function

创造建材数字转型新视界,中建材如何多边赋能集团业务快速发展

GRUB2的零日漏洞补丁现已推出

2022年SQL大厂高频实战面试题(详细解析)
![[供应链·案例篇]石油和天然气行业的数字化转型用例](/img/44/9ef9f86f8afb85f49aac1cce55723d.jpg)
[供应链·案例篇]石油和天然气行业的数字化转型用例

Leetcode75. Color Classification

【Day_12 0507】查找组成一个偶数最接近的两个素数

QLineEdit learning and use

C language theory--a solid foundation for the written test and interview

MySQL Lock wait timeout exceeded; try restarting transaction 锁等待
随机推荐
LeaRun.net快速开发动态表单
What is the JVM runtime data area and the JMM memory model
What is the implementation principle of Go iota keyword and enumeration type
Tower Defense Shoreline User Agreement
C language theory--a solid foundation for the written test and interview
How to solve the dynamic binding of el-form-item prop attribute does not take effect
ExcelPatternTool: Excel表格-数据库互导工具
三种方案解决:npm WARN config global --global, --local are deprecated. Use --location=global instead.
SQL的ROUND函数用法及其实例
C语言理论--笔试面试基础稳固
golang json 返回空值
想做期货,农产品期货怎么炒?波动大么
【Day_09 0427】走方格的方案数
我在启牛开户安全吗?谁能告诉我开不靠谱?
CodeTON Round 2 (Div. 1 + Div. 2, Rated, Prizes!) Solution
QT commonly used global macro definitions
QT_事件类
B011 - 基于51的多功能指纹智能锁
SQL的索引详细介绍
食品安全 | 新鲜食品vs速食食品,哪一种是你的菜?