繁体   English   中英

iOS 15 导航栏透明问题

[英]iOS 15 Navigation Bar Transparent issue

在 iOS 15 中为 NavigationBar 尝试 Transperent,

它在低于 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。 在此处输入图片说明

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

appearance.configureWithOpaqueBackground()

到:

appearance.configureWithTransparentBackground()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM