如何更改标签栏控制器项目名称的字体大小?

Man*_*epa 16 iphone xcode objective-c

我正在做一个基于tabbarController的应用程序.我有3个tabbar项目.

我的问题是:如何更改标签栏项目标题的字体样式?

小智 12

[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]];
Run Code Online (Sandbox Code Playgroud)

  • 对于仍然遇到此问题的任何人:上面键入的方法不正确.你需要在`setTitleTextAttributes:`之后添加`forState:`参数.然后它会在没有警告的情况下编译并按预期工作. (3认同)