答案 0 :(得分:0)
extension UINavigationBar {
var customStyle: NavigationBarCustomStyle {
set(style) {
switch style {
case .clear:
self.setBackgroundImage(UIImage(), for: .default)
self.shadowImage = UIImage()
self.tintColor = .white
self.isTranslucent = false
break
case .bottomLine:
self.tintColor = .gray
self.backgroundColor = .yellow
self.isTranslucent = false
break
}
}
get {
return self.customStyle
}
}
}
enum NavigationBarCustomStyle {
case clear
case bottomLine
// case white
}
在ViewController >> viewDidLoad方法放在下面的行:
self.navigationController?.navigationBar.customStyle = .clear
答案 1 :(得分:0)
尝试将导航栏的背景颜色设置为白色(具体取决于您的情况),尽管仍然存在其他故障,但它会更好一些:)
override func viewDidLoad() {
super.viewDidLoad()
self.navigationController?.view.backgroundColor = .white
}