How do you set the font size from a UILabel
?
My code:
UILabel *myView = [[UILabel alloc] initWithFrame:RectFrame]; [myView setBackgroundColor:[UIColor blueColor]]; [myView setText:[NSString stringWithFormat:@" A"]]; [myView setFont:[12] ]; <--- Error [self.view addSubview:myView];
You can just make use of the same function that you call in setFont which is [UIFont fontWithName:size:] .
Instead just go to the properties of whatever you're trying to change the font size of, and go to the font property. Click on the 3 dots (...) and a box will open. In that box, you can change the font and its size too.
[myView setFont:[UIFont systemFontOfSize:12]];
or
[myView setFont:[UIFont boldSystemFontOfSize:12]];
or for font family
[myView setFont:[UIFont fontWithName:@"Helvetica" size:12]];
If your UILabel
's font is defined in IB
storyboard
and you just want to increase size then this will work, worked for me ;)
[_label setFont: [_label.font fontWithSize: sizeYouWant]];
Or
[self.label setFont: [self.label.font fontWithSize: sizeYouWant]];
Another method as others says also worked:
[_label setFont:[UIFont systemFontOfSize:13.0]];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With