2012-04-23 10 views
13

私はTabBarの外観などiOS5をTabBarのフォントと色

UIImage *tabBackground = [[UIImage imageNamed:@"tab-bar-bg.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)]; 
[[UITabBar appearance] setBackgroundImage:tabBackground]; 
[[UITabBar appearance] setSelectionIndicatorImage: [UIImage imageNamed:@"activetab.png"]]; 

をカスタマイズしたどのように私は、カスタムフォントと選択し、選択されていないテキストの色を定義していますか?

おかげで、

+1

forState:UIControlStateHighlightedがhttp://stackoverflow.com/a/8412083/886407 – JiaYow

+0

ああ邪悪を見てください変更すべきだと思います!私は検索してみましたが、明らかに十分ではありません!ありがとう! –

答えて

18
[[UITabBarItem appearance] setTitleTextAttributes: 
    [NSDictionary dictionaryWithObjectsAndKeys: 
     [UIColor blackColor], UITextAttributeTextColor, 
     [UIFont fontWithName:@"font" size:0.0], UITextAttributeFont, 
     nil] 
              forState:UIControlStateHighlighted]; 
+1

これはiOS 5以降でのみ動作します。 –

+0

タイトルのエッジインセットを設定するにはどうすればよいですか? –

+0

@BurhanuddinSunelwala setTitlePositionAdjustment:(UIOffset)調整 – JerryZhou

13
[[UITabBarItem appearance] setTitleTextAttributes: 
    [NSDictionary dictionaryWithObjectsAndKeys: 
     [UIColor blackColor], UITextAttributeTextColor, 
     [UIFont fontWithName:@"ProximaNova-Semibold" size:0.0], UITextAttributeFont, 
     nil] 
              forState:UIControlStateHighlighted]; 


    [[UITabBarItem appearance] setTitleTextAttributes: 
    [NSDictionary dictionaryWithObjectsAndKeys: 
     [UIColor grayColor], UITextAttributeTextColor, 
     [UIFont fontWithName:@"ProximaNova-Semibold" size:0.0], UITextAttributeFont, 
     nil] 
              forState:UIControlStateNormal]; 
1

は、上記の答えは私のために働いています。

しかし、私はほとんどの人がforstate:UIControlStateSelected

関連する問題