all images I put in Images.xcassets, so I can use images by [UIImage imageNamed:]. but when I open App, the tabBar not show all icons before I switch the tabItem or wait a moment.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[[UITabBar appearance] setTintColor:[UIColor colorWithRed:228/255.0 green:118/255.0 blue:54/255.0 alpha:1]];
NSArray *tabBarItems = ((UITabBarController *)self.window.rootViewController).tabBar.items;
NSArray *tabBarItemsTitle = @[@"TabGift", @"TabOnly", @"TabMissfresh", @"TabMine", @"TabCart"];
[tabBarItems enumerateObjectsWithOptions:NSEnumerationConcurrent
usingBlock:^(UITabBarItem *item, NSUInteger itemIndex, BOOL *stop) {
[item setTitle:NSLocalizedString(tabBarItemsTitle[itemIndex], tabBarItemsTitle[itemIndex])];
UIImage *image = [UIImage imageNamed:tabBarItemsTitle[itemIndex]];
[item setImage: image];
if ([tabBarItemsTitle[itemIndex] isEqualToString:@"TabMissfresh"]) {
[item setSelectedImage:[[UIImage imageNamed:@"TabMissfreshSelected"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
}
}];
return YES;
}
When I open my App, tabBar look like this:
This is my Images.xcassets: