Rahul
Rahul

Reputation: 5834

how to change font size of label without changing font family in xcode

how to change font size of label without changing font family in xcode6 ?I am using following line of code:

lblMain.font =  [UIFont systemFontOfSize:22];

Upvotes: 1

Views: 2953

Answers (4)

CarlHere
CarlHere

Reputation: 43

[lblMain setFont:[UIFont fontWithName:@"HelveticaNeue" size:17]];

Upvotes: 1

alinoz
alinoz

Reputation: 2822

NSString *fontName = lblMain.font.fontName;
CGFloat fontSize = lblMain.font.pointSize;

[lblMain setFont:[UIFont fontWithName:fontName size:NEWSIZE]];

Upvotes: 2

YogevSitton
YogevSitton

Reputation: 10108

Here's an example:

lblMain.font = [UIFont fontWithName:@"HelveticaNeue" size:22];

Or - you can even use the current font:

lblMain.font = [lblMain.font fontWithSize:22];

Upvotes: 6

Salman Zaidi
Salman Zaidi

Reputation: 9842

Use following code, if you just want to change font size keeping the same font family:

lblMain.font = [UIFont fontWithName:lblMain.font.fontName size:22.0f];

OR

You can also use this code:

lblMain.font = [lblMain.font fontWithSize:22.0f];

Upvotes: 1

Related Questions