自定义时,UITabBar
我有两种方法可以做到这一点,但我很好奇什么是最好的方法,两种方法都有哪些优点和缺点?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UITabBarController *tbc = (UITabBarController *)self.window.rootViewController;
UITabBar *tb = tbc.tabBar;
// 1. Customizing UITabBar using appearance proxy:
[[UITabBar appearance] setBackgroundImage:[UIImage imageNamed:@"tabbar.png"]];
[[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageNamed:@"tabbar_selected.png"]];
// 2. Doing the same by setting the properties directly:
// tb.backgroundImage = [UIImage imageNamed:@"tabbar.png"];
// tb.selectionIndicatorImage = [UIImage imageNamed:@"tabbar_selected.png"];
return YES;
}