透明导航栏iOS13
Transparent navigation bar iOS 13
无法创建透明的 NavigationBar iOS 13.
我有自定义 UINavigationBar,我在其中配置 UINavigationBarAppearance
override init(frame: CGRect) {
super.init(frame: frame)
self.configure()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
self.configure()
}
配置代码:
let appearance = UINavigationBarAppearance()
appearance.configureWithTransparentBackground()
appearance.shadowColor = .clear
appearance.backgroundColor = .clear
并将其设置为:
self.compactAppearance = appearance
self.standardAppearance = appearance
self.scrollEdgeAppearance = appearance
结果我得到了这个:
预期结果:NavigationBar 应该是透明的
修改外观代码为:-
let appearance = UINavigationBarAppearance()
appearance.configureWithTransparentBackground()
appearance.shadowColor = .clear
appearance.backgroundColor = .clear
appearance.backgroundImage = nil
appearance.shadowImage = nil
适合我:
self.compactAppearance = appearance
self.standardAppearance = appearance
self.scrollEdgeAppearance = appearance
self.backgroundColor = appearance.backgroundColor
无法创建透明的 NavigationBar iOS 13.
我有自定义 UINavigationBar,我在其中配置 UINavigationBarAppearance
override init(frame: CGRect) {
super.init(frame: frame)
self.configure()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
self.configure()
}
配置代码:
let appearance = UINavigationBarAppearance()
appearance.configureWithTransparentBackground()
appearance.shadowColor = .clear
appearance.backgroundColor = .clear
并将其设置为:
self.compactAppearance = appearance
self.standardAppearance = appearance
self.scrollEdgeAppearance = appearance
结果我得到了这个:
预期结果:NavigationBar 应该是透明的
修改外观代码为:-
let appearance = UINavigationBarAppearance()
appearance.configureWithTransparentBackground()
appearance.shadowColor = .clear
appearance.backgroundColor = .clear
appearance.backgroundImage = nil
appearance.shadowImage = nil
适合我:
self.compactAppearance = appearance
self.standardAppearance = appearance
self.scrollEdgeAppearance = appearance
self.backgroundColor = appearance.backgroundColor