改变tabbar编辑视图控制器的色调

我想要更改标签栏控制器的编辑视图控制器的色调颜色。 我设法改变了更多的视图控制器的颜色,但没有得到这个线索。

这个代码是改变更多的视图控制器的颜色,写在UITabBarController的subcalss

  override func viewDidLoad() { super.viewDidLoad() var view = self.moreNavigationController.topViewController.view as UITableView view.tintColor = Utilities.mainColor() view.separatorStyle = .None } 

Objective-C或Swift都欢迎提出build议

在这里输入图像说明

通过尝试下面的代码为我工作

  override func viewDidLoad() { super.viewDidLoad() //this line helped me self.view.tintColor = Utilities.mainColor() } 

您可以为tabBarItem手动设置彩色图像。

 UIImage *defaultImage = [UIImage imageNamed:@"sports"]; defaultImage = [defaultImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];//system tints wont apply on the default image UIImage *selectedImage = [[UIImage imageNamed:@"sports"] imageWithColor:tintColor]; selectedImage = [selectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];//System tints wont apply on this image UITabBarItem *item = [[UITabBarItem alloc] initWithTitle:@"Sports" image:defaultImage selectedImage:selectedImage]; } 

以下function可用于手动对图像着色

 - (UIImage *)imageWithColor:(UIColor *)color1 { UIGraphicsBeginImageContextWithOptions(self.size, NO, self.scale); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextTranslateCTM(context, 0, self.size.height); CGContextScaleCTM(context, 1.0, -1.0); CGContextSetBlendMode(context, kCGBlendModeNormal); CGRect rect = CGRectMake(0, 0, self.size.width, self.size.height); CGContextClipToMask(context, rect, self.CGImage); [color1 setFill]; CGContextFillRect(context, rect); UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return newImage; }