if (@available(iOS 15.0, *)) {
UINavigationBarAppearance *appearance = [[UINavigationBarAppearance alloc] init];
appearance.backgroundColor = [UIColor colorWithHexString:@"#F8F8F8"]; //背景色
appearance.shadowColor = UIColor.clearColor; //阴影
self.navigationController.navigationBar.standardAppearance = appearance;
self.navigationController.navigationBar.scrollEdgeAppearance = appearance;
}
或
AppDelegate - didFinishLaunchingWithOptions新增
if (@available(iOS 13.0, *)) {
UINavigationBarAppearance *appearance = [[UINavigationBarAppearance alloc] init];
appearance.backgroundColor = [UIColor colorWithHexString:@"#F8F8F8"]; //背景色
appearance.shadowColor = UIColor.clearColor; //阴影
[[UINavigationBar appearance] setStandardAppearance:appearance];
[[UINavigationBar appearance] setScrollEdgeAppearance:appearance];
}
网友评论