【问题标题】:Navigation bar and tab bar turned black on iOS15 Xcode 13iOS15 Xcode 13导航栏和标签栏变黑
【发布时间】:2021-11-16 22:32:15
【问题描述】:

今天我刚刚将我的 Xcode 更新到版本 13,发现我的项目的所有导航栏和标签栏都变黑了,我没有更改任何设置,我的项目在 Xcode 12 上运行良好,我已经切换到light模式,我找不到恢复旧外观的方法。

【问题讨论】:

    标签: swift xcode storyboard ios15


    【解决方案1】:

    只需在属性检查器中检查“半透明”即可。

    【讨论】:

      【解决方案2】:

      应用以下代码来更新导航栏的外观。如果您希望它成为整个应用程序的外观,可以在 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
      

      【讨论】:

        【解决方案3】:

        像这样:

        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

        【讨论】:

        • 嗨,有什么办法可以在故事板上更改它们,因为故事板上的视图控制器不应该看起来像那样
        猜你喜欢
        • 1970-01-01
        • 2018-12-23
        • 1970-01-01
        • 2012-02-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-01-10
        相关资源
        最近更新 更多