我一直在尝试更改选项卡栏项目的字体,但是我找不到任何Swift示例。我知道这是您在Objective-C中进行的更改:
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:@"AmericanTypewriter" size:20.0f], UITextAttributeFont, nil] forState:UIControlStateNormal];
但是如何将其转换为Swift?
UITextAttributeFont在iOS 7中已弃用。您应该改用NS变体:
import UIKit let appearance = UITabBarItem.appearance() let attributes = [NSFontAttributeName:UIFont(name: "American Typewriter", size: 20)] appearance.setTitleTextAttributes(attributes, forState: .Normal)