Is there a way to add custom fonts to Xcode to be

2019-07-30 11:58发布

This question already has an answer here:

I know how to add custom font files to be shipped with an iOS app. I can then customize the label font from code using code like this :

UIFont* font = [UIFont fontWithName:@"League Gothic" size:42];
self.topLabel.font = font;

My concern is that such customization will "infect" all of the project and may require some significant rework later on. Is there a way to include a font file into xCode itself, so it recognizes it and lets me select it from the storyboard font control?

2条回答
叼着烟拽天下
2楼-- · 2019-07-30 12:41

Another way to achieve it without having to relay on exposing IBOutlets or adding external libraries is using categories and user defined runtime attributes from Storyboard or Interface Builder.

That way you can define your fonts in Storyboard or IB like this:

Runtime Attributes

You can get the code required for the categories from this response.

查看更多
\"骚年 ilove
3楼-- · 2019-07-30 12:49

You can find the answer to this question over here

Designing labels/text views with custom fonts in Interface Builder

You can find a link regarding the same topic here

http://www.abdus.me/ios-programming-tips/set-custom-fonts-in-interface-builder/

Hope this helps you.

查看更多
登录 后发表回答