【发布时间】: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 uinavigationcontroller navigationbar uinavigationbarappearance