Using default icons in UITabbar

I am using a tab control in my application and want to use the default search icon on one of my tabs. I am making the tab bar programmatically, but I cannot find a property where I can specify the UITabBarSystemItemSearch element that I found in the Apple documentation. The following is my code for the tab bar

CouponsViewController *coupons = [[CouponsViewController alloc] init]; UINavigationController *couponsNavigationController = [[UINavigationController alloc] initWithRootViewController:coupons]; couponsNavigationController.tabBarItem.title = @"Coupons"; couponsNavigationController.navigationBar.tintColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.1]; [coupons release]; SettingsViewController *settings = [[SettingsViewController alloc] init]; UINavigationController *settingsNavigationController = [[UINavigationController alloc] initWithRootViewController:settings]; settingsNavigationController.tabBarItem.title = @"Settings"; settingsNavigationController.navigationBar.tintColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.1]; [settings release]; ProfileViewController *profile = [[ProfileViewController alloc] init]; UINavigationController *profileNavigationController = [[UINavigationController alloc] initWithRootViewController:profile]; profileNavigationController.tabBarItem.title = @"Profile"; profileNavigationController.tabBarItem.image = [UIImage imageNamed:@"profileImg.png"]; profileNavigationController.navigationBar.tintColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.1]; [profile release]; [tabBarController setViewControllers:[NSArray arrayWithObjects:loyaltyNavigationController,searchNavigationController,couponsNavigationController,settingsNavigationController,profileNavigationController,nil] animated:NO]; tabBarController.delegate=self; tabBarController.selectedIndex=0; [window addSubview:tabBarController.view]; 
+4
source share
1 answer

execute this code in a subclass of UIViewController that you put in the tab bar. This is best done in the initializer method of your view:

 - (id) init { self.title = @"search"; self.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemSearch tag:0]; return self; } 
+10
source

Source: https://habr.com/ru/post/1306766/


All Articles