导航栏和标签栏在iOS15 Xcode 13上变成了黑色。

5
今天我刚刚将我的Xcode更新到13版本,发现我的项目中所有的导航栏和选项卡栏都变成了黑色。我没有改变任何设置,我的项目在Xcode 12上可以正常运行,并且我已经切换到了浅色模式,但是我无法找到恢复旧外观的方法。 enter image description here enter image description here
3个回答

3
只需在属性检查器中勾选“半透明”即可。 enter image description here

0

应用以下代码来更新导航栏的外观。如果您希望在整个应用程序中使用相同的外观,则可以在AppDelegate中完成此操作。

let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.titleTextAttributes = [NSAttributedString.Key.foregroundColor: .black]
appearance.backgroundColor = .white
// Default portrait view
UINavigationBar.appearance().standardAppearance = appearance
// There are other appearances you could apply it to as well...
// UINavigationBar.appearance().scrollEdgeAppearance = appearance
// UINavigationBar.appearance().compactAppearance = appearance

0

像这样:

let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = .red
appearance.titleTextAttributes = [.font: 
UIFont.boldSystemFont(ofSize: 20.0),
                              .foregroundColor: UIColor.white]

// Customizing our navigation bar
navigationController?.navigationBar.tintColor = .white
navigationController?.navigationBar.standardAppearance = appearance
navigationController?.navigationBar.scrollEdgeAppearance = appearance

我写了一篇新文章谈论它。

https://medium.com/@eduardosanti/uinavigationbar-is-black-on-ios-15-44e7852ea6f7


嗨,有没有办法在Storyboard上更改它们?因为Storyboard上的视图控制器不应该看起来像那样。 - Zim

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接