2

この回答に従って、バーアイテムのテキストの色を白に変更しましたが、タブバーアイテムが6つあり、システムボタン[詳細]アイテムを取得してテキストの色を変更できません。

この[詳細]ボタンのテキストの色を白に変更するにはどうすればよいですか?どうも。

もっとボタンを見てください

私のコード:

for (UITabBarItem* item in self.tabBar.items)
{
    NSLog(@"title:%@",item.title); // only get my items
    [item setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                  [UIFont fontWithName:@"AmericanTypewriter" size:11.0f], UITextAttributeFont,
                                  [UIColor whiteColor], UITextAttributeTextColor,
                                  [UIColor clearColor], UITextAttributeTextShadowColor,
                                  [NSValue valueWithUIOffset:UIOffsetMake(0.0f, 1.0f)], UITextAttributeTextShadowOffset,
                                  nil] forState:UIControlStateNormal];
}
4

1 に答える 1

2

あなたはこれを試しましたか、それは私のために働いています:

[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                             [UIFont fontWithName:@"AmericanTypewriter" size:20.0f], UITextAttributeFont,
                                             [UIColor yellowColor], UITextAttributeTextColor,
                                             [UIColor redColor], UITextAttributeTextShadowColor,
                                             [NSValue valueWithUIOffset:UIOffsetMake(0.0f, 1.0f)], UITextAttributeTextShadowOffset,
                                             nil] forState:UIControlStateNormal];

または、self.myTabBarを[UITabBarItemappearance]に置き換えます

于 2012-12-10T15:36:39.173 に答える