Search This Blog

Monday 15 July 2013

Customising and using UIFonts

Hi Friends,

I am going to explain you how to add and use customised UIFonts in our app.

When you have UIFont files such as .otf etc. you can simply use it in your code.

Lets start with following steps,

1.Add all UIFont files (.otf etc) in project bundle (drag and drop in project) and select copy and add to Target.It will show the fonts in project.

2.Go to .plist file of your project and create Array new entry as 'Fonts provided by application'.

3.Add key in that item 0,item 1,etc. based on your number of fonts you want to use and their values should be the names of Font files.for eg. Value of item 0 can be 'MyriadPro-Regular.otf' etc.Here, 'MyriadPro-Bold' is the name of font.

We are done with it.Now we need to use this fonts.Its the normal way you are setting UIFonts.

If I want to set the custom font to tableView cell then I write,


            cell.textLabel.font = [UIFont fontWithName:@"MyriadPro-Regular" size:20];

In this way you can simply use this fonts in your code.

Feel free to comment.

Happy coding :)