iOS15导航栏变透明

  • 内容
  • 评论
  • 相关
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
if (@available(iOS 13.0, *)) {
    UINavigationBarAppearance *appearance = [UINavigationBarAppearance new];
    appearance.shadowImage = [UIImage imageWithColor:KWhiteColor];
    [appearance configureWithOpaqueBackground];
    appearance.backgroundColor =  KWhiteColor;
     
    nav.navigationBar.standardAppearance = appearance;
    nav.navigationBar.scrollEdgeAppearance = appearance;
    [nav.navigationBar setShadowImage:nil];
    [nav.navigationBar setShadowImage:[UIImage imageWithColor:KWhiteColor]];
     
    [nav.navigationBar setBackgroundImage:       [UIImage imageWithColor:KWhiteColor] forBarMetrics:UIBarMetricsDefault];
     
     
} else {
    // Fallback on earlier versions
}
1
2
3
4
5
6
7
8
9
10
11
12
13
//全局设置  
 if (@available(iOS 13.0, *)) {
        UINavigationBarAppearance *appearance = [[UINavigationBarAppearance alloc] init];
        [appearance configureWithOpaqueBackground];
        appearance.backgroundColor = kWhiteColor;
 
        [[UINavigationBar appearance] setStandardAppearance:appearance];
        [[UINavigationBar appearance] setScrollEdgeAppearance:appearance];
    } else {
        // Fallback on earlier versions
        [[UINavigationBar appearance] setBarTintColor:kWhiteColor];
        [[UINavigationBar appearance] setTranslucent:NO];
    }

评论

0条评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注