how to change the style of the font programmatically in objective-c

lakesh picture lakesh · Jan 5, 2013 · Viewed 17.8k times · Source

I would like to change the style of the font (like bold, regular, light, oblique) programmatically. I know I can use the IB, but I would like to change it using programmatically. Need some guidance on this. Sorry if it is a stupid question.

For example, my code looks like this:

lblAge.font = [UIFont fontWithName:@"Helvetica" size:20];

I would like to add the style which is regular in. How do I it?

Answer

Dalee Davis picture Dalee Davis · Jan 5, 2013

This should get you going

offerTitle.font = [UIFont fontWithName:@"TimesNewRomanPS-ItalicMT" size:14.0f];//here offerTitle is the instance of `UILabel` 

Hope this helps:)