3.iOS15.0适配背景颜色透明

configureWithOpaqueBackground

1.UITabBarAppearance

    if (@available(iOS 13.0, *)) {
        UITabBarAppearance *tabBarAppearance = [[UITabBarAppearance alloc] init];
        [tabBarAppearance configureWithOpaqueBackground];
        tabBarAppearance.backgroundImage = [self createImageWithColor:[UIColor colorWithRed:249/255.0 green:251/255.0 blue:252/255.0 alpha:1.0]];
        tabBarAppearance.shadowColor = [UIColor colorWithRed:249/255.0 green:251/255.0 blue:252/255.0 alpha:1.0];
        self.tabBar.standardAppearance = tabBarAppearance;
        if (@available(iOS 15.0, *)) {
            self.tabBar.scrollEdgeAppearance = tabBarAppearance;
        }
     }
 /** 导航栏变成透明需要重写 */
        UINavigationBarAppearance *appearance = [UINavigationBarAppearance new];
        [appearance configureWithOpaqueBackground];
        appearance.backgroundColor = [UIColor whiteColor];
        //去掉导航栏下的阴影线
        appearance.shadowColor= [UIColor clearColor];
        NSMutableDictionary *titleDic = [NSMutableDictionary dictionary];
        [titleDic setValue:[UIColor whiteColor] forKey:NSForegroundColorAttributeName];
        appearance.titleTextAttributes = titleDic;
        self.navigationBar.standardAppearance = appearance;
        self.navigationBar.scrollEdgeAppearance = self.navigationBar.standardAppearance;

你可能感兴趣的:(3.iOS15.0适配背景颜色透明)