iOS15导航栏变透明

  • 内容
  • 评论
  • 相关
    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
    }
//全局设置   
 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条评论

发表回复

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