如何在iPhone SDK中使用自定义字体?
我想在我的应用中实现自定义字体。所以我在我的项目源代码中添加了它。我不想以编程方式设置它。我可以通过在xib中设置属性来实现这一点吗?
I Want to implement custom font in my app. So i have added that in my Project Source code. I don't want to set that programatically. Is this possible that I can do this with setting properties in xib?
-
将自定义字体添加到项目中,即将字体文件(
CALIBRIZ_0.TTF
)拖到XCode项目中。
Add your custom font into your project , i.e. Dragged the font file(
CALIBRIZ_0.TTF
) into XCode project.
编辑Info.plist :添加一个新条目,其中包含
应用程序提供的字体键。
Edit Info.plist: Add a new entry with the key "Fonts provided by application".
对于每个文件,将文件名添加到此数组
For each of your files, add the file name to this array
打开字体书中的字体(在Finder中双击字体)看看真正的文件名是什么,
我看到了这个:
Opened the font in font book(double click on your font in finder) to see what the real filename is and I see this:
现在将字体设置为你的标签
yourLabel.font = [UIFont fontWithName:@"Calibri" size:15];
关注这个以获得更多