IOS changes tabbar Image Rendering-do not let tabbat have blue rendering and modify text,
Method 1: code implementation this requires a lot of code. Every controller needs to write UIImage * image = [UIImage imageNamed: @ "tabBar_friendTrends_click_icon"]; // key code for rendering at the bottom of the tabbar: image = [image imageWithRenderingMode: UIImageRenderingModeAlwaysOriginal]; vc01.tabBarItem. selectedImage = image; change the text style, size, color NSMutableDictionary * atts = [dictionary]; // change the text size atts [NSFontAttributeName] = [UIFont systemFontOfSize: 12]; // change the text color. atts [NSForegroundColorAttributeName] = [UIColor darkGrayColor]; NSMutableDictionary * selectedAtts = [NSMutableDictionary dictionary];
SelectedAtts [NSFontAttributeName] = [UIFont systemFontOfSize: 12];
SelectedAtts [NSForegroundColorAttributeName] = [UIColor greenColor]; [vc01.tabBarItem setTitleTextAttributes: selectedAtts forState: UIControlStateSelected]; method 2 in Assets. after the changes in the xcassets folder are made, no code is required and will be applied to the specific appearance attribute in all controllers. // you can use appearance to set the text attribute of all UITabBarItem in a unified manner. // The text attribute with UI_APPEARANCE_SELECTOR method, you can use appearance to agree to set text attribute cases such as UITabBarItem;
NSMutableDictionary * atts = [NSMutableDictionary dictionary];
Atts [NSFontAttributeName] = [UIFont systemFontOfSize: 12];
Atts [NSForegroundColorAttributeName] = [UIColor grayColor];
NSMutableDictionary * selectedAtts = [NSMutableDictionary dictionary];
SelectedAtts [NSFontAttributeName] = atts [NSFontAttributeName]; selectedAtts [NSForegroundColorAttributeName] = [UIColor darkGrayColor]; // you only need to change it here, change all text to UITabBarItem * item = [UITabBarItem appearance];
[Item setTitleTextAttributes: atts forState: UIControlStateNormal];
[Item setTitleTextAttributes: selectedAtts forState: UIControlStateSelected];
// Add a sub-Controller
UIViewController * vc01 = [[UIViewController alloc] init];
Vc01.view. backgroundColor = [UIColor redColor];
Vc01.tabBarItem. title = @ "excellent ";
Vc01.tabBarItem. image = [UIImage imageNamed: @ "tabBar_essence_icon"];
UIImage * image = [UIImage imageNamed: @ "tabBar_friendTrends_click_icon"];
// Key code for rendering at the bottom of the tabbar: image = [image imageWithRenderingMode: UIImageRenderingModeAlwaysOriginal]; vc01.tabBarItem. selectedImage = image; // Add the Controller to UITabBarController to [self addChildViewController: vc01];
UIViewController * vc02 = [[UIViewController alloc] init];
Vc02.tabBarItem. title = @ "New Post ";
Vc02.tabBarItem. image = [UIImage imageNamed: @ "tabBar_new_click_icon"];
Vc02.tabBarItem. selectedImage = [UIImage imageNamed: @ "tabBar_new_click_icon"];
Vc02.view. backgroundColor = [UIColor cyanColor];
[Self addChildViewController: vc02];
UIViewController * vc03 = [[UIViewController alloc] init];
Vc03.view. backgroundColor = [UIColor blueColor];
Vc03.tabBarItem. title = @ "follow ";
Vc03.tabBarItem. image = [UIImage imageNamed: @ "tabBar_friendTrends_icon"];
Vc03.tabBarItem. selectedImage = [UIImage imageNamed: @ "tabBar_friendTrends_click_icon"];
[Self addChildViewController: vc03];
UIViewController * vc04 = [[UIViewController alloc] init];
Vc04.tabBarItem. title = @ "me ";
Vc04.tabBarItem. image = [UIImage imageNamed: @ "tabBar_me_icon"];
Vc04.tabBarItem. selectedImage = [UIImage imageNamed: @ "tabBar_me_click_icon"];
Vc04.view. backgroundColor = [UIColor yellowColor]; [self addChildViewController: vc04];