customize tabbar icon and text color

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
- (void)configTabBar {
UIColor *greenColor = [UIColor colorWithRed:0.213
green:0.898
blue:0.573
alpha:1.000];
[self.tabBar.items
enumerateObjectsUsingBlock:^(UITabBarItem *obj, NSUInteger idx, BOOL *stop) {
[obj setTitleTextAttributes:@{
NSForegroundColorAttributeName: [UIColor whiteColor],
}
forState:UIControlStateNormal];
[obj setTitleTextAttributes:@{
NSForegroundColorAttributeName: greenColor,
}
forState:UIControlStateSelected];
obj.image = [[UIImage imageNamed:@"tabbar_icon".addInt(idx)] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
obj.selectedImage = [UIImage imageNamed:@"tabbar_icon".addInt(idx)];
}];
}