Reputation: 1562
I have a problem at changing the font size in an UILabel dynamically. In my app, I have two labels.
Now the problem is, The first label's font size may vary during run time. I have to change the second label's font size according to the first label's font size.
I have used the following method but it doesn't works.
CGFloat secondLabelsize = firstLabel.font.pointSize;
[seconLabel setFont: [UIFont fontWithName: @"Exo-Light" size:secondLabelsize]];
viewDidLod
{
[hr_lbl setFont: [UIFont fontWithName: @"Exo-Light" size:55]];
}
Every time i have got label size as 55 only. Pls suggest me a to get current font size(first label) instead of defined font size at viewdidload.
Upvotes: 4
Views: 320
Reputation: 1562
Here is the answer,
label2.frame.size.width == label1.frame.size.width;
Note : if i use singe "=" its an error. If i use "==" it gives a warning but gives expected output too. Really confused what's happening there. Any one please guide me to understand this.
Upvotes: 5
Reputation: 2022
The @"Exo-Light" font is not able to be set to 55. It'a a font issue. Try using sandart @"Helvetica" to make sure the code works, then find a font closer to your exo-light (that will behave correctly, of course).
Also make sure the labels are properly hooked up in xib.
Upvotes: 2