I have a UITabBarController that I am trying to modify. Right now the UNselected tab icon images are default gray. I know that you cant change the tint of these UNselected icon images programmatically. Apple says that the tint is controlled by the actual tint of the png file itself. So if you want a white or green icon image then you have to use a png that displays the image as white or green etc. After that you must use UIImageRenderingModeAlwaysOriginal AND initWithTitle:image:selectedImage: I used this code in my FirstViewController.m and i placed it in the -(void)viewDidLoad. However, I am getting a parse issue: expected identifier and its pointing at the bracket after nil. Does anybody see the issue with this code?
//
// FirstViewController.m
// tabmock5
//
// Created by USER on 9/26/13.
// Copyright (c) 2013 USER. All rights reserved.
//
#import "FirstViewController.h"
@interface FirstViewController ()
@end
@implementation FirstViewController
- (void)viewDidLoad
{
[[UIImage imageNamed:@"white_stats.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
[self.tabBarItem initWithTitle:[nil]image:[UIImage imageNamed:@"white_stats.png"]selectedImage:[UIImage imageNamed:@"white_stats.png"]];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
This isn't saving the image anywhere. Change it to:
And this:
nil
isn't an object (it doesn't go in square brackets). Change this to:Alternatively, you can technically do this in one line:
But that is hard to read if you need to come back to it later, so don't do that.