如何在 UINavigationBar 中设置自定义字体?我需要 tahoma 字体。
- (void)viewDidLoad{
self.title =@"My text";
}
最佳答案
完全有可能,只是做起来有点棘手。一旦你找到了你需要的字体(iOS 已经附带的替代品之一,或者你已经获得正确许可的 TTF 文件),只需创建一个包含大小、格式、字体等的 UILabel,然后添加将其设置为该栏的导航项(或者,如果您在 View Controller 中执行此操作,则将该 Controller 的 .navigationItem.titleView 设置为您的标签)。
例如,我在 UINavigationController 中有一个 View Controller 。要将顶部的标签更改为自定义字体,我只需执行以下操作:
//...I have already setup a UILabel called navLabel that has the same style as a
// default navigation bar title, but I've changed the .font property to my custom font
self.navigationItem.titleView = navLabel;
[navLabel release];
关于iphone - 如何在 UINavigationBar 中设置自定义字体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4699905/