Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 369
lakshmen Avatar asked Jan 05 '13 08:01

lakshmen


2 Answers

This should get you going

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

Hope this helps:)

like image 104
Dalee Davis Avatar answered Dec 21 '22 21:12

Dalee Davis


Try this solution:

myLabel.font = [UIFont boldSystemFontOfSize:16.0f];
myLabel.font = [UIFont italicSystemFontOfSize:16.0f];

For regular size:

myLabel.font = [UIFont systemFontOfSize:16.0f];

Hope it helps you.

like image 30
P.J Avatar answered Dec 21 '22 19:12

P.J