Adding custom font of your choice or of your business theme, in your iOS app is quite important. Custom fonts can enrich your app and transform it from just and app to an awesome app. Adding custom font in iOS application is a step by step process. In this article we have listed all the steps and in order, we have provided enough images so that you do not lose the track
A demo project has been created in which we will add a custom font. We assume that you have the basic knowledge of creating projects creating outlets and you have a custom font file. To begin with the demo app is a simple app with a UILabel and default font.
- Go to your custom font folder and drag the font file in your project
- Font Name and Font File name are two different things and are both required to get Font Name open your font file. The resulting font book will display your font name and type.
After clicking on font file font book will open and will display actual Font Name
Our font is Roboto and type is Thin
- Now we need to add font file in Project -> Target -> Copy Bundle Resources
click on the “+” icon and add font file from the resulting drop down
- Add your font file name in info.plist -> Fonts provided by application -> item 0 (Roboto-Thin.ttf)
This is most overlooked and missed step 😉
- Now in order to see the effect make outlet of the label in ViewController named
lblCustomFont
- Add the custom font to your UILabel using following code.You can do it in any method
self.lblCustomFont.font = UIFont(name:"Roboto-Thin", size: 25.0)
- Now run the application you will be able to see your custom font applied 🙂
Using same steps you can add any number of custom fonts in your application.