当前位置:网站首页>暑假第二周总结博客
暑假第二周总结博客
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。
边栏推荐
- How to use the Golang coroutine scheduler scheduler
- 三维空间中点的插值
- DBPack SQL Tracing 功能及数据加密功能详解
- 突破性能天花板!亚信数据库支撑 10 多亿用户,峰值每秒百万交易
- 移动端吸顶方案
- RecSys'22|CARCA: Cross-Attention-Aware Context and Attribute Recommendations
- 理财产品的月年化收益率怎么算?
- GTK修改pixmap像素,提取pixmap像素RGB值
- Xingtu has been short of disruptive products?Will this M38T from the Qingdao factory be a breakthrough?
- B001 - 基于STM32的智能生态鱼缸
猜你喜欢
随机推荐
Xingtu has been short of disruptive products?Will this M38T from the Qingdao factory be a breakthrough?
计算IoU(D2L)
Topology零部件拆解3D可视化解决方案
关于MySql中explain结果filtered的理解
小贝拉机器人是朋友_普渡科技召开新品发布会,新一代送餐机器人“贝拉”温暖登场...
QT_QThread thread
中信证券是国内十大券商吗?怎么开户安全?
快速抽取resnet_v2_152中间的特征层
QT basic functions, signals, slots
QLineEdit学习与使用
QT commonly used global macro definitions
How to solve the dynamic binding of el-form-item prop attribute does not take effect
EpiSci | Deep Reinforcement Learning for SoCs: Myth and Reality
JVM运行时数据区与JMM内存模型是什么
Shell nl命令详解(显示行号、读取文件)
What is the JVM runtime data area and the JMM memory model
存储日报-数据湖架构权威指南(使用 Iceberg 和 MinIO)
如何让固定点的监控设备在EasyCVR平台GIS电子地图上显示地理位置?
MySql 怎么查出符合条件的最新的数据行?
关于单应性矩阵的若干思考








