我一直在尝试获得透明的navigationBar
,但是它变成黑色。
这是我用来使其透明的代码:
navigationController?.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
navigationController?.navigationBar.shadowImage = UIImage()
navigationController?.navigationBar.isTranslucent = true
答案 0 :(得分:0)
您可以试用此UINavigationBar
扩展名
使用
navigationController?.navigationBar.makeTransparent()
扩展
public extension UINavigationBar {
/// - Parameter tint: tint color (default is .white).
public func makeTransparent(withTint tint: UIColor = .white) {
setBackgroundImage(UIImage(), for: .default)
shadowImage = UIImage()
isTranslucent = true
tintColor = tint
titleTextAttributes = [NSAttributedStringKey.foregroundColor: tint]
}
}