iOS 15 UITabBarController的选项卡栏背景颜色变为黑色 [英] iOS 15 UITabBarController's tabBar background color turns black

查看:102
本文介绍了iOS 15 UITabBarController的选项卡栏背景颜色变为黑色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

tabBar.barTintColor在iOS 15测试版4中无法更改。

背景。我们在App Store中有一个应用程序,每年在新的iOS主要版本发布之前,我们都会下载iOS测试版,并测试我们的应用程序以提前修复问题。

我们的问题。今年,当在iOS15beta4中测试时,我们发现UITabBarController的选项卡栏背景颜色变黑,使得项目(图标和标题)难以阅读。在我们的代码中,self.tabBar.barTintColor=.White,这行代码在iOS 15中不起作用。

我们的尝试。我在网上搜索,发现一个相似但不完全相同的问题报告,https://developer.apple.com/forums/thread/682420。我尝试了standardAppearance,但这不是解决方案,因为使用appearance我无法更改tabBar.tintColor

推荐答案

我遇到了相同的问题,并且找到了您问题中的相同链接。我对选项卡栏使用了相同的方法。

这是我正在使用的代码,它工作正常。

if #available(iOS 15.0, *) {
   let appearance = UITabBarAppearance()
   appearance.configureWithOpaqueBackground()
   appearance.backgroundColor = customColor
   
   self.tabController.tabBar.standardAppearance = appearance
   self.tabController.tabBar.scrollEdgeAppearance = view.standardAppearance
}

这篇关于iOS 15 UITabBarController的选项卡栏背景颜色变为黑色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆