我想知道是否有人能帮助我解决我目前遇到的问题。我试图更改UITabBar
的实际字体,我已经能够选择文本时的文本颜色和颜色。我到目前为止的代码在这里:
//Setting tab bar background
UIImage* tabBarBackground = [UIImage imageNamed:@"tabbar.png"];
[[UITabBar appearance] setBackgroundImage:tabBarBackground];
//[[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageNamed:@"selected.png"]];
// Changes Selected Image color
[[UITabBar appearance] setTintColor:[UIColor colorWithRed:33.0/255.0 green:35.0/255.0 blue:38.0/255.0 alpha:1.0]]; //Icon colour
// Changes StateNormal text Color,
[UITabBarItem.appearance setTitleTextAttributes: @{NSForegroundColorAttributeName : [UIColor colorWithRed:214.0/255 green:69.0/255 blue:65.0/255 alpha:1.0]} forState:UIControlStateNormal]; //Colour of text when not seleted
// Changes StateSelected
UIColor *titleHighlightedColor = [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0]; //Colour of text when selected
[UITabBarItem.appearance setTitleTextAttributes: @{NSForegroundColorAttributeName : titleHighlightedColor} forState:UIControlStateSelected];
我想知道是否有人会知道是否有可能在这里更改字体,如果有的话我会怎么想这样做?代码位于AppDelegate.m
中提前致谢,
哈里森
答案 0 :(得分:2)
尝试将其添加到标题文字属性中:
[UITabBarItem.appearance setTitleTextAttributes: @{
NSForegroundColorAttributeName : [UIColor colorWithRed:214.0/255 green:69.0/255 blue:65.0/255 alpha:1.0],
NSFontAttributeName : [UIFont systemFontOfSize:20]
} forState:UIControlStateNormal];
答案 1 :(得分:0)
您可以使用
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:@"Arial" size:5.0f], NSFontAttributeName, nil] forState:UIControlStateNormal];