我们如何在 iOS 应用中使用自定义字体?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13029660/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can we use custom font in an iOS app?
提问by Dev
Possible Duplicate:
Can I embed a custom font in an iPhone application?
How can I customize font in my iPhone app?
Is it possible?
How can I use this custom font in a UILabel
?
如何在我的 iPhone 应用程序中自定义字体?是否可以?如何在UILabel
.
I am trying to add MYRIADPRO-SEMIBOLD.OTF
font in my App.
我正在尝试MYRIADPRO-SEMIBOLD.OTF
在我的应用程序中添加字体。
and the code is
代码是
UIFont *customFont = [UIFont fontWithName:@"MYRIADPRO-SEMIBOLD" size:35];
titleLbl.font = customFont;
And the Plist is
而 Plist 是
回答by Kamar Shad
Try the steps below:
请尝试以下步骤:
1. Make configuration in the info.plist as shown in Image
1. 在 info.plist 中进行配置,如图
2. Now you should use that added file
2. 现在你应该使用添加的文件
UIFont *customFont = [UIFont fontWithName:@"fontName" size:size];
// further you may set That Font to any Label etc.
EDIT:Make Sure you have added that file in your resources Bundle.
编辑:确保您已将该文件添加到您的资源包中。
回答by edzio27
Copy your font file into Resources.
In your application .plist create (if it exists just create a row) a row called
Fonts provided by application
and then initem 0
copy your font name for exampleCiutadella-Bold.otf
Then you can define this font in your application:
UIFont *CiutadellaBold = [UIFont fontWithName:@"Ciutadella-Bold" size:17.0f];
And use it in for instance in
UILabel
:[uiLabel setFont:CiutadellaBold];
将您的字体文件复制到资源中。
在您的应用程序 .plist 中创建(如果它存在,则创建一行)名为的行
Fonts provided by application
,然后item 0
复制您的字体名称,例如Ciutadella-Bold.otf
然后你可以在你的应用程序中定义这个字体:
UIFont *CiutadellaBold = [UIFont fontWithName:@"Ciutadella-Bold" size:17.0f];
并将其用于例如
UILabel
:[uiLabel setFont:CiutadellaBold];
回答by IronManGill
It is totally possible. Please check the following links to implement your solution.
这是完全可能的。请检查以下链接以实施您的解决方案。
iPhone Development: how to use custom fonts?
How to add custom fonts to an iPhone app?
how to use custom font in iphone application
Can I embed a custom font in an iPhone application?
I hope these links help.
我希望这些链接有帮助。