iOS15解决导航条适配问题
解决 适配 问题 导航条
2023-09-11 14:14:25 时间
在旧版本代码中设置导航条颜色使用的是navigationBar.barTintColor,但在iOS15上并没有生效,而且navigationBar.isTranslucent=NO也没有生效,导航条依然是透明的。
解决方案:
if (@available(iOS 15.0, *)) {
UINavigationBarAppearance *appearance = [[UINavigationBarAppearance alloc] init];
[appearance configureWithOpaqueBackground];
//设置导航条背景色
appearance.backgroundColor = UIColor.whiteColor;
//设置导航条标题颜色
NSMutableDictionary *attributes = [NSMutableDictionary dictionary];
[attributes setValue:UIColor.blackColor forKey:NSForegroundColorAttributeName];
appearance.titleTextAttributes = attributes;
[UINavigationBar appearance].standardAppearance = appearance;
[UINavigationBar appearance].scrollEdgeAppearance = appearance;
}
[UINavigationBar appearance].backgroundColor = UIColor.whiteColor;
[UINavigationBar appearance].barTintColor = UIColor.whiteColor;
[UINavigationBar appearance].titleColor = UIColor.blackColor;
同理可以设置tabbar的颜色
if (@available(iOS 15.0, *)) {
UITabBarAppearance * appearance = [[UITabBarAppearance alloc] init];
[appearance configureWithOpaqueBackground];
appearance.backgroundColor = UIColor.whiteColor;
[UITabBar appearance].scrollEdgeAppearance = appearance;
[UITabBar appearance].standardAppearance = appearance;
}
[UITabBar appearance].backgroundColor = UIColor.whiteColor;
相关文章
- java 解决 java.lang.Integer cannot be cast to java.lang.String
- SPSS提示“列表中不同意存在字符串变量”的解决方法
- 【转】解决keepalived正常启动但是虚IP(VIP)没有生成的问题
- win11内存完整性打不开的解决方法
- failed to load steamui.dll怎么解决?
- Vue - 完美解决 Element UI 侧边导航菜单 <el-menu> 出现滚动条,去掉 Element 侧边导航组件的横纵滚动条(但滚动功能依然保留,仅仅是去掉 “滚动条“)100% 解决方案
- 如何解决微信小程序界面适配问题-引用-生命周期回调函数-优化机制-样式引入
- Tortoise SVN 不显示 Log Message 具体信息的解决方法
- 解决WMI Provide Host占用CPU过高问题(win10亲测有用)
- Sublime Text 无法使用Package Control或插件安装失败的解决方法
- 【报错】解决node: bad option:-V
- vue项目中使用了vw适配方案,引入第三方ui框架mint-ui时,适配问题解决
- 解决每编译一段代码,便需要clean一下项目的问题
- 利用原生子窗体解决悬浮窗口播放的问题及踩坑记录
- Vite 使用记录:动态导入静态图片、vite项目报错Only file and data URLs are supported by the default ESM loader解决、Vite多环境配置
- Vagrant box ubuntu/xenial64 添加vagrant用户解决没有登录密码的问题
- “TNS-03505:无法解析名称”问题解决一例
- 关于解决DevExpress用DevExpress patch工具破解后经常弹出试用框的问题