iOS 26 Beta 3中UITabBar未选中项暗黑模式下文字显示异常(无法阅读)的问题咨询
iOS 26 Beta 3中UITabBar未选中项暗黑模式下文字显示异常(无法阅读)的问题咨询
大家好,我在iOS 26 Beta 3版本遇到了一个UITabBar的显示问题,想请教下有没有朋友遇到过或者知道问题出在哪:
我在一个背景色设为systemBackground的页面上使用了UITabBar,结果在暗黑模式下,未选中的Tab项文字变成了黑色,和背景几乎融为一体,完全无法阅读。但奇怪的是,同样的场景用SwiftUI实现就一切正常,而且系统自带的应用也没有这个问题。
下面是我的相关代码,麻烦大家帮忙看看哪里可能有问题:
SceneDelegate 相关代码
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { guard let windowScene = (scene as? UIWindowScene) else { return } window = .init(windowScene: windowScene) let tabVC = Self.makeTabVC() window?.rootViewController = tabVC window?.makeKeyAndVisible() } static func makeTabVC() -> UIViewController { let tabVC = UITabBarController(tabs: [ .init(title: "View 1", image: .init(systemName: "1.circle"), identifier: "Tab.vc1", viewControllerProvider: { _ in return ViewController(text: "View 1", color: .systemBackground) }), .init(title: "View 2", image: .init(systemName: "2.circle"), identifier: "Tab.vc2", viewControllerProvider: { _ in return ViewController(text: "View 2", color: .blue) }) ]) return tabVC }
ViewController 代码
class ViewController: UIViewController { convenience init(text: String, color: UIColor) { self.init(nibName: nil, bundle: nil) self.text = text self.color = color } var text: String! var color: UIColor! private var label: UILabel! override func viewDidLoad() { super.viewDidLoad() label = UILabel() view.addSubview(label) label.center = view.center label.translatesAutoresizingMaskIntoConstraints = false label.text = text label.sizeToFit() NSLayoutConstraint.activate([ label.centerXAnchor.constraint(equalTo: view.centerXAnchor), label.centerYAnchor.constraint(equalTo: view.centerYAnchor) ]) view.backgroundColor = color } }
有没有朋友能帮我分析下,是我哪里的配置或者代码逻辑有问题吗?
内容来源于stack exchange
相关产品推荐
相关产品推荐

