美文网首页iOS学习笔记ios 知识点
iOS tabbar默认渲染蓝色的问题

iOS tabbar默认渲染蓝色的问题

作者: NiuBaBa | 来源:发表于2016-07-08 14:40 被阅读1624次

在使用tabBarViewController的时候,会遇到在tabBar中显示的图片和颜色被渲染成为蓝色的问题。
解决方法如下:
1、关闭图片的自动渲染

UIImage *selectIMG = [UIImage imageNamed:[NSString stringWithFormat:@"btm_hover_icon2.png"]];
selectIMG = [selectIMG imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
fistVC.tabBarItem.selectedImage=selectIMG;

这种方法可以单独将图片设置成为禁止进行自动渲染。

2、整体设置图片的颜色(可分被选择状态和正常状态)

UITabBarItem *itm=[UITabBarItem appearance];
    
[itm setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor groupTableViewBackgroundColor]} forState:UIControlStateNormal];
    
[itm setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor orangeColor]} forState:UIControlStateSelected];
    

3、将系统渲染的颜色进行更改
这个是整体更改的,包括颜色和文本。
在AppDelegate.m中

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    //tabbar 默认的渲染颜色为蓝色  这里是将默认的渲染颜色改为红色 包括图片和字体
    [[UITabBar appearance] setTintColor:[UIColor redColor]];
    return YES;
}

相关文章

网友评论

    本文标题:iOS tabbar默认渲染蓝色的问题

    本文链接:https://www.haomeiwen.com/subject/ynqrjttx.html