【问题标题】:iOS 15 Navigation Bar Transparent issueiOS 15 导航栏透明问题
【发布时间】:2021-12-24 19:27:50
【问题描述】:

在 iOS 15 中尝试透明的 NavigationBar,

它在低于 iOS 15 的版本中工作。

override func viewDidLoad() {
        // Clear the background image.
        self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
        // Clear the shadow image.
        self.navigationController?.navigationBar.shadowImage = UIImage()
        // Ensure the navigation bar is translucent.
        self.navigationController?.navigationBar.isTranslucent = true

        if #available(iOS 15, *) {
            let appearance = UINavigationBarAppearance()
            appearance.configureWithOpaqueBackground()
            appearance.shadowImage = UIImage()
            appearance.backgroundColor = .clear
            UINavigationBar.appearance().standardAppearance = appearance
            UINavigationBar.appearance().scrollEdgeAppearance = appearance
        }
}

如何在 iOS 15 中让 NavigationBar 透明。

【问题讨论】:

    标签: ios uinavigationcontroller navigationbar uinavigationbarappearance


    【解决方案1】:

    如果你想要一个透明的导航栏.. 改变这一行:

    appearance.configureWithOpaqueBackground()
    

    到:

    appearance.configureWithTransparentBackground()
    

    【讨论】:

    • 非常感谢,你太棒了
    猜你喜欢
    • 2021-11-05
    • 2021-12-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-21
    • 2020-09-19
    • 2018-03-05
    • 2016-12-20
    相关资源
    最近更新 更多