UITabbar及UITabbarItem颜色问题

1.去掉UITabBarController背景色自带的蒙版

        [tabbarController.tabBarsetBackgroundColor:[UIColorwhiteColor]];

        [tabbarController.tabBarsetBackgroundImage:[UIImagenew]];

并且注意

     [UITabBar appearance].barStyle = UIBarStyleDefault;

可以看看Black的效果

2.设置UITabBarController上UITabbarItem的字体颜色及选中态颜色

        NSMutableDictionary *attr3=[NSMutableDictionary dictionary];

        attr3[NSForegroundColorAttributeName]=[UIColor blackColor];

        attr3[NSFontAttributeName]=[UIFontsystemFontOfSize:CTabbarFontSize];

        [[UITabBarItem appearance]setTitleTextAttributes:attr3 forState:UIControlStateNormal];

        NSMutableDictionary *attr4=[NSMutableDictionary dictionary];

        attr4[NSForegroundColorAttributeName]=[UIColor redColor];

        attr4[NSFontAttributeName]=[UIFontsystemFontOfSize:CTabbarFontSize];

        [[UITabBarItem appearance]setTitleTextAttributes:attr4 forState:UIControlStateSelected];

3.关于UITabbar一开始颜色正确,进入页面再出来后颜色错误的问题,是因为退出后按钮显示的是你设置的setTintColorColor

所以要增加tintcolor与上面的arrt4一致。

  [tabbarController.tabBarsetTintColor:[UIColor  redColor]];

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容