可能重复:
我可以在iPhone应用程序中嵌入自定义字体吗?
如何在我的iPhone应用程序中自定义字体?可能吗?如何为标签提供此自定义字体?有谁能建议一个好的方法?
我试图在我的应用程序中添加MYRIADPRO-SEMIBOLD.OTF字体.
而代码是
UIFont *customFont = [UIFont fontWithName:@"MYRIADPRO-SEMIBOLD" size:35];
titleLbl.font = customFont;
Run Code Online (Sandbox Code Playgroud)
Plist是

Kam*_*had 67
请尝试以下步骤.
1在info.plist中进行配置,如图所示

现在你应该使用添加的文件
UIFont *customFont = [UIFont fontWithName:@"fontName" size:size];
// further you may set That Font to any Label etc.
Run Code Online (Sandbox Code Playgroud)
编辑:确保您已在资源包中添加该文件.

将您的字体文件复制到资源中
在您的应用程序.plist中创建(如果它存在只是创建一行)一行称为"由应用程序提供的字体",然后在"项目0"中复制您的字体名称,例如"Ciutadella-Bold.otf"
然后,您可以在应用程序中定义此字体:
UIFont *CiutadellaBold = [UIFont fontWithName:@"Ciutadella-Bold" size:17.0f];
Run Code Online (Sandbox Code Playgroud)并在例如uiLabel中使用:
[uiLabel setFont:CiutadellaBold];
Run Code Online (Sandbox Code Playgroud)| 归档时间: |
|
| 查看次数: |
31784 次 |
| 最近记录: |