// 设置导航栏的标题颜色,字体
NSDictionary* textAttrs = @{NSForegroundColorAttributeName:
[UIColor whiteColor],
NSFontAttributeName:
[UIFont fontWithName:@"Helvetica-Bold"size:17.0],
};
// [self.navigationController.navigationBar setTitleTextAttributes:textAttrs];
if (@available(iOS 13.0, *)) {
UINavigationBarAppearance *barApp = [[UINavigationBarAppearance alloc] init];
[barApp configureWithOpaqueBackground];
barApp.titleTextAttributes = textAttrs;
barApp.backgroundColor = [UIColor redColor];
self.navigationController.navigationBar.standardAppearance = barApp;
self.navigationController.navigationBar.scrollEdgeAppearance = barApp;
} else {
// Fallback on earlier versions
[self.navigationController.navigationBar setTitleTextAttributes:textAttrs];
}
网友评论