I already know how to change the colour of an image of a UITabBarItem
(from this answer: https://stackoverflow.com/a/25062766/887353), but how can I change the colour of its text? I haven't figured it out. Also, how can I change the colour of the image and the text if the UITabBarItem
is selected? I use Swift with iOS 7 and 8.
Asked
Active
Viewed 2,219 times
0
2 Answers
4
For Swift:
UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName : UIColor(red: CGFloat(1), green: CGFloat(1), blue: CGFloat(1), alpha: CGFloat(1))], forState: UIControlState.Normal)

tester
- 3,977
- 5
- 39
- 59
0
For TabBar selected image, you'll need to use UIImageRenderingModeAlwaysOriginal
or else the image will have a blue tint
.
UITabBarItem *tabBarItem1 = [[self.tabBar items] objectAtIndex:0];
tabBarItem1.selectedImage = [[UIImage imageNamed:@""] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

Sreejith
- 1,345
- 13
- 25