I'm trying to set the font size of a UILabel. No matter what value I put though the text size doesn't seem to change. Here's the code I'm using.
[self setTitleLabel:[[UILabel alloc] initWithFrame:CGRectMake(320.0,0.0,428.0,50.0)]]; [[self contentView] addSubview:[self titleLabel]]; UIColor *titlebg = [UIColor clearColor]; [[self titleLabel] setBackgroundColor:titlebg]; [[self titleLabel] setTextColor:[UIColor blackColor]]; [[self titleLabel] setFont:[UIFont fontWithName:@"System" size:36]];
To set a different font on UIButton programmatically you will need to create a new instance of UIFont object. The initializer of UIFont accepts two arguments: name and size. where the “GillSans-Italic” is a font name you want to set.
You can set the Minimum Font Scale or size in Storyboard/Xib when you set it up in IB under the Attributes inspector. I prefer scale, as it is better at fitting longer text on iPhone 4/5/iPod touches. If you set the size, you can get cut off earlier than with scale.
Try [UIFont systemFontOfSize:36]
or [UIFont fontWithName:@"HelveticaNeue" size:36]
i.e. [[self titleLabel] setFont:[UIFont systemFontOfSize:36]];
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