I have an app where I am setting the font for a UILabel programmatically as below
[label setFont:[UIFont fontWithName:fontName size:[fontSize intValue]]];
wherein fontName
is a string type variable that hold font name such as "Helvetica"
and fontSize
will hold the size of the font. This works fine for me.
Now I want to make this text "Bold" how can I do that?
boldSystemFontOfSize
works for system font. How can I achieve the same for user defined fonts ?
Thanks.
Try using @"Helvetica-Bold"
as the fontName.
Try this,
NSArray *arr = [UIFont fontNamesForFamilyName:@"myFavoriteFont"];
NSString *fontName = [arr objectAtIndex:0]; //or [arr objectAtIndex:1], it depends
[label setFont:[UIFont fontWithName:fontName size:[fontSize intValue]]];
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