簡體   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