UILabel - 设置自定义字体

Son*_*oni 2 uilabel ios

我想将GillSans-Bold字体添加到UILabel.我已经在xib文件中设置了它,我也在我的课堂中设置它,如下所示:

[label setFont:[UIFont fontWithName:@"GillSans-Bold" size:18]];
Run Code Online (Sandbox Code Playgroud)

但是,它似乎对我不起作用.有什么建议 ?

Jan*_*ano 12

iPhone 4.3没有Gill Sans,但iPad自3.2.1以来就有.

请参阅此列表,比较iPad 4.3和iPhone 4.3的字体.可以肯定的是,这是您获取设备上可用字体列表的方法:

for (NSString *familyName in [UIFont familyNames]) {
    for (NSString *fontName in [UIFont fontNamesForFamilyName:familyName]) {
        NSLog(@"%@", fontName);
    }
}
Run Code Online (Sandbox Code Playgroud)

如果它说

GillSans
GillSans-Bold
GillSans-BoldItalic
GillSans-Italic
Run Code Online (Sandbox Code Playgroud)

然后[UIFont fontWithName:@"GillSans-Bold" size:18]应返回有效的字体.