iOS tabbar横线颜色及tabbar背景色设置,tabbar字体颜色 大小设置

1.tabbar横线颜色

if (@available(iOS 13.0, *)) {

        UITabBarAppearance *standardAppearance = [[UITabBarAppearance alloc] init];

        standardAppearance.backgroundColor = [UIColor whiteColor];//根据自己的情况设置

        standardAppearance.shadowColor = [UIColor clearColor];//也可以设置为白色或任何颜色

        self.tabBar.standardAppearance = standardAppearance;

    }else{

        [[UITabBar appearance] setBackgroundImage:[[UIImage alloc]init]];

        [[UITabBar appearance] setShadowImage:[[UIImage alloc]init]];

        [UITabBar appearance].backgroundColor = [UIColor whiteColor];//根据自己的情况设置

    }

2.修改tabbar背景色

- (void)setTabbarBackGround{


    if(@available(iOS 13.0, *)) {

        UITabBarAppearance *appearance = [self.tabBar.standardAppearance copy];

        appearance.backgroundImage = [selfcreateImageWithColor:[UIColor clearColor]];

        appearance.shadowImage = [selfcreateImageWithColor:[UIColor clearColor]];

        //下面这行代码最关键

        [appearance configureWithTransparentBackground];

        self.tabBar.standardAppearance = appearance;


    }else{

            [self.tabBar setBackgroundImage:[selfcreateImageWithColor:[UIColor clearColor]]];

        [self.tabBar setShadowImage:[selfcreateImageWithColor:[UIColor clearColor]]];

        self.tabBar.translucent =YES;


    }

}

3.设置tabbar字体颜色 大小

 if(@available(iOS 13.0, *)) {

        // iOS13 及以上

        self.tabBar.tintColor = [UIColor colorWithHexString:@"#FF0009"];

        self.tabBar.unselectedItemTintColor = [UIColor colorWithHexString:@"#333333"];

        UITabBarItem *item = [UITabBarItem appearance];

        [item setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]} forState:UIControlStateNormal];

        [item setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]} forState:UIControlStateSelected];

    }

    else{

        // iOS13 以下

        UITabBarItem *item = [UITabBarItem appearance];

        [item setTitleTextAttributes:@{ NSForegroundColorAttributeName:[UIColor colorWithHexString:@"#333333"],NSFontAttributeName:[UIFont systemFontOfSize:14]} forState:UIControlStateNormal];

        [item setTitleTextAttributes:@{ NSForegroundColorAttributeName:[UIColor colorWithHexString:@"#FF0009"],NSFontAttributeName:[UIFont systemFontOfSize:14]} forState:UIControlStateSelected];

    }

你可能感兴趣的:(iOS tabbar横线颜色及tabbar背景色设置,tabbar字体颜色 大小设置)