问题
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?
回答1:
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.
回答2:
Another way to achieve it without having to relay on exposing IBOutlet
s 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:
You can get the code required for the categories from this response.
来源:https://stackoverflow.com/questions/17278395/is-there-a-way-to-add-custom-fonts-to-xcode-to-be-available-from-a-storyboard