using default icons in UITabbar
i am using tab bar control in my app and want to use the default search icon in one of my tab. I am making the tab bar programmically but i am not able to find a property where i can specify UITabBarSystemItemSearch item which i find in apple documentation. Following is my code for 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 arra开发者_高级运维yWithObjects:loyaltyNavigationController,searchNavigationController,couponsNavigationController,settingsNavigationController,profileNavigationController,nil] animated:NO];
tabBarController.delegate=self;
tabBarController.selectedIndex=0;
[window addSubview:tabBarController.view];
execute this code in your UIViewController subclass that you are putting into the tab bar. This is best done in your view controller's initializer method:
- (id) init
{
self.title = @"search";
self.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemSearch
tag:0];
return self;
}
精彩评论