我有一個關於自定義UITabBarItem故事板 - 如何定製UITabbarItem與裏面的UITabBarController UINavigationController的
首先的問題,您可以download my code demo
現在,我定製的UITabBarController在MyAppDelegate是:
-(void)configureiPhoneTabBar
{
tabViewController = (UITabBarController *)self.window.rootViewController;
UIViewController *controller1 = [[tabViewController viewControllers] objectAtIndex:0];
[self configureTabBarItemWithImageName:@"home_ON.png" : @"home.png" andText:@"Home" forViewController:controller1];
UIViewController *controller2 = [[tabViewController viewControllers] objectAtIndex:1];
[self configureTabBarItemWithImageName:@"tvChannel_ON.png" : @"tvChannel.png" andText:@"TV" forViewController:controller2];
}
-(void)configureTabBarItemWithImageName:(NSString*)imageName1 : (NSString*)imageName2 andText:(NSString *)itemText forViewController:(UIViewController *)viewController
{
UIImage* icon1 = [UIImage imageNamed:imageName1];
UIImage* icon2 = [UIImage imageNamed:imageName2];
UITabBarItem *item1 = [[UITabBarItem alloc] initWithTitle:itemText image:icon1 tag:0];
[item1 setTitleTextAttributes:@{ UITextAttributeTextColor : [UIColor whiteColor] }
forState:UIControlStateNormal];
[item1 setFinishedSelectedImage:icon1 withFinishedUnselectedImage:icon2];
[viewController setTabBarItem:item1];
}
我在UINavigationController裏面使用了一個UITabbarcontroller,並且我無法從appdelegate自定義uitabaritem,如果你運行代碼並在UITabBarController中檢查「initial」,界面顯示爲true,但是當在「in itial「很難做到這一點
感謝您的快速回復,它工作正常:) – BlueSky