当前位置:网站首页>暑假第二周总结博客
暑假第二周总结博客
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。
边栏推荐
- 数字化采购管理系统开发:精细化采购业务流程管理,赋能企业实现“阳光采购”
- Are online account opening commissions reliable? Is online account opening safe?
- Topology Parts Disassembly 3D Visualization Solution
- Leetcode75. 颜色分类
- B005 - STC8 based single chip microcomputer intelligent street light control system
- MySQL 慢查询
- ACID Characteristics and Implementation Methods of MySQL Relational Database Transactions
- 频域分析实践介绍
- 【无标题】setInterval和setTimeout详解
- 生物制药产业发展现状和趋势展望
猜你喜欢

B011 - 基于51的多功能指纹智能锁

el-form-item prop属性动态绑定不生效如何解决

What is the JVM runtime data area and the JMM memory model

QLineEdit学习与使用

DBPack SQL Tracing 功能及数据加密功能详解

生物制药产业发展现状和趋势展望

广汽埃安“弹匣电池”,四大核心技术,出行安全保障
Detailed explanation of DBPack SQL Tracing function and data encryption function

Leetcode73. 矩阵置零

今年最火爆的词:商业分析,看这一篇就够了!
随机推荐
Solve the problem that MySQL cannot insert Chinese data
B001 - 基于STM32的智能生态鱼缸
bat 批示处理详解-2
QT_Event class
typora操作手册
SQL函数 TO_DATE(二)
MySQL Lock wait timeout exceeded; try restarting transaction 锁等待
我在启牛开户安全吗?谁能告诉我开不靠谱?
DBPack SQL Tracing 功能及数据加密功能详解
Leetcode72. Edit Distance
MySQL 45 讲 | 09 普通索引和唯一索引,应该怎么选择?
Leetcode72. 编辑距离
【Translation】OpenMetrics cultivated by CNCF becomes an incubation project
XAML WPF item groupBox control
想做期货,农产品期货怎么炒?波动大么
B002 - Embedded Elderly Positioning Tracking Monitor
B011 - 51-based multifunctional fingerprint smart lock
QT_QThread thread
一加OnePlus 10RT出现在Geekbench上 产品发布似乎也已临近
突破性能天花板!亚信数据库支撑 10 多亿用户,峰值每秒百万交易