导航栏为图片的时候,进入是白色的,需要往上滑一点才能出现
OC
UIImage *bgImage = [[UIImage imageNamed:@"nav_other"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0) resizingMode:UIImageResizingModeStretch];
if (@available(iOS 13.0, *)) {
UINavigationBarAppearance *barApp = [UINavigationBarAppearance new];
[barApp setBackgroundImage:bgImage];
self.navigationController.navigationBar.scrollEdgeAppearance = barApp;
self.navigationController.navigationBar.standardAppearance = barApp;
} else {
// Fallback on earlier versions
}
swift
if #available(iOS 13.0, *) {
let barApp = UINavigationBarAppearance.init()
barApp.backgroundImage = bgImg
self.navigationController?.navigationBar.scrollEdgeAppearance = barApp
self.navigationController?.navigationBar.standardAppearance = barApp
barApp.titleTextAttributes = [NSAttributedString.Key.font: UIFont.italicSystemFont(ofSize: 16),NSAttributedString.Key.foregroundColor: UIColor.white]
barApp.titleTextAttributes =
[NSAttributedString.Key.foregroundColor: UIColor.white]
}