Reputation: 1433
I have font of an testLabel
as Helvetica Neue 12.0
in compact width
and compact height
class, which I set on the storyboard.
I did this in viewWillAppear
override func viewWillAppear(_ animated: Bool) {
testLabel.font = UIFont(name: "HelveticaNeue", size: 18)}
But the font did not change in the simulator. How do I override the size of font programtically?
Upvotes: 4
Views: 431
Reputation: 645
Try to change you UILabel font in viewDidLayoutSubviews
method.
Objective C:
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
// CHANGE YOUR LABEL FONT
}
Swift:
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
// CHANGE YOUR LABEL FONT
label.font = UIFont(name: "HelveticaNeue", size: 18)
}
It will work..
Upvotes: 4