[英]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
}
}
如果你想要一個透明的導航欄..改變這一行:
appearance.configureWithOpaqueBackground()
到:
appearance.configureWithTransparentBackground()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.