Starting for iOS 3.2, it is possible to use custom fonts in your iOS application. Read about how to add custom fonts in my earlier post.
But there’s much more to custom fonts.
Set Global Appearance
You can also set the appearance in your AppDelegate
[[UILabel appearance] setFont:[UIFont fontWithName:@"CustomFont-Regular" size:17.0]];
However, this is a rather naive approach as it will fix the size (above exammple all font will be size 17).
Set only font family
So a better approach is this.
In each of your ViewController
viewDidLoad, you can
setFontFamily for the view and it’s subview, while maintaining the font size. But you have to do it for every view controller.
Use Runtime Attributes
You can change the font in Xcode using user defined runtime attributes.
There is a good solution on Stackoverflow. Not sure who is the original author, but cavaspod.io uses the same code too. The technique is using category for UILabel, UIButton, UITextField, UITextView, and also UINavigationBar.
While good, it could be tedious to add key value for every UI element you want custom font for.
IBCutomFonts replace a natively supported font with a custom font. For example, replace all
It uses method sizzling for
fontWithName method, so it is a dangerous way.
Somehow, I could not get it to work correctly for iOS 7.
It’s not recommended, although one of the cleanest way to replace all fonts.
MoarFont for $10
This is an app that shows up the custom font in Xcode. For $10. I didn’t try it.
I ended up using only 2 solutions:
Write code to set font family for a view which has many components
Use cavaspod.io to set runtime attributes for the rest