Pages

Friday 24 May 2013

Adding custom font in ios app

The addition of custom font ios app is very easy and hardly take 2 mints. When first time my team lead gave me this task I was thinking it will be a difficult task and take minimum 30 mints, but when I start it take hardly 2 mints. So do not worry with the name "custom font" just start it.....

Step 1

Download your required font file having .otf extension. In this post I am using " MyriadPro Bold" which can be download from this link.
Add the downloaded file in your project. After that  go to info.plist file and add "Fonts provided by application".



Now add new item under "Fonts provided by application" and give the name of font file with extension.



Step 2

Now its time to write code, go to .m file and write the code of setting font.





 font=[UIFont fontWithName:@"MyriadPro-Bold" size:17];
 [self.label setFont:font];



That's it. Does it take more than 2 mint???????


Note: Make sure that font file (which you have included in your project) is also present in bundle resources. Mostly xcode automatically include it but some time it does not, In this case you will have to do it manually.