2012-09-05 101 views
1

沒有任何人知道如何使用外觀代理對象如何自定義UITabBar文本標籤?

[[UITabBar appearance] set....]; 

以自定義的UITabBar的選定/未選定標籤的顏色,字體和陰影?

非常感謝。

回答

2

通過訪問UITabBar標籤欄項目對象爲每個UIViewController

這僅適用於iOS5.0或更高版本的作品。

if ([self.tabBarItem respondsToSelector:@selector(setTitleTextAttributes:)]) { 
    NSLog(@"*** Support method(iOS 5): setTitleTextAttributes:"); 
    [self.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: 
               [UIFont fontWithName:@"AmericanTypewriter" size:20.0f], UITextAttributeFont, 
               [UIColor blackColor], UITextAttributeTextColor, 
               [UIColor grayColor], UITextAttributeTextShadowColor, 
               [NSValue valueWithUIOffset:UIOffsetMake(0.0f, 1.0f)], UITextAttributeTextShadowOffset, 
               nil]]; 
} 

低於5 https://github.com/boctor/idev-recipes/tree/master/CustomTabBar