UITabBarController

我是前言: 今天朋友问我的, 以前遇到过, 时间很久了, 忘记了, 记录一下 , 解决方法如下:

// 选中图片应该这样
mainVc.tabBarItem.selectedImage = [[UIImage imageNamed:@"image_"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
// 文字颜色改变
[mainVc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName :[UIColor colorWithRed:0.2373 green:1.0 blue:0.8771 alpha:1.0]} forState:UIControlStateSelected];
// 解决tabbar选中图片偏移
navMain.tabBarItem.image = [UIImage imageNamed:@"主页图标@2x.png"];
navMain.tabBarItem.selectedImage = [[UIImage imageNamed:@"name"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
UIEdgeInsets insets = UIEdgeInsetsMake(6, 0, -6, 0);
navMain.tabBarItem.imageInsets = insets;

你可能感兴趣的:(UITabBarController)