問題
最近接手一個老項目,發現每次push一個新VC,導航欄狀態欄都默認爲黑色,並且在滾動的過程中漸變成白色,到處搜索都沒定位到哪裏配置了backgroundColor = blackColor
解決方案
其實是iOS13後蘋果更新UINavigationBar屬性參數配置問題引起,配置以下方法解決:
if (@available(iOS 13.0, *)) {
UINavigationBarAppearance *appearance = [UINavigationBarAppearance new];
[appearance configureWithOpaqueBackground];//重置導航欄背景顏色和陰影
appearance.backgroundColor = [UIColor whiteColor];
// appearance.shadowImage = [UIImage new];
// appearance.shadowColor = nil;
self.navigationController.navigationBar.standardAppearance = appearance;
self.navigationController.navigationBar.scrollEdgeAppearance = appearance;
}