我在我的应用程序中使用collectionView并将状态栏样式设置为亮起并将 hidesBarsOnSwipe
的 navigationController
设置为true . 但是当我向上滚动单元格时,navigationController会隐藏,但状态栏会变为黑色 . 滚动collectionView向下时返回白色 . 这是我的navigationController代码:
extension UINavigationController {
override open var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}
func transparentNavigation() {
guard let pacificoFont = UIFont(name: "Pacifico", size: 20) else {return}
navigationBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.foregroundColor, NSAttributedStringKey.font: pacificoFont]
navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
navigationBar.shadowImage = UIImage()
navigationBar.isTranslucent = true
view.backgroundColor = .clear
hidesBarsOnSwipe = true
}
}
有没有办法修复这个“功能”?
1 回答
当您有一个
translucent
导航栏时,状态栏会从导航栏中获取其颜色 . 因此,当导航栏滚动时,状态栏将降为默认的黑色 .如果您希望
translucent
导航栏和状态栏具有特定颜色(如白色),则可以使用你可以在
ViewDidLoad
中添加它希望这可以帮助