How to create bold UIFont

HurkNburkS picture HurkNburkS · Jan 17, 2012 · Viewed 56.8k times · Source

I am doing some word wrapping in my tableview as some of the values are so big they go off the edge of the screen.

However, the font and size and boldness dose not match the default settings of the table view and was hoping someone could help me fix that up.

This is what I am doing to set the fields:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *cellText = @"Go get some text for your cell.";
    UIFont *cellFont = [UIFont fontWithName:@"Helvetica" size:17.0];
    CGSize constraintSize = CGSizeMake(280.0f, MAXFLOAT);
    CGSize labelSize = [cellText sizeWithFont:cellFont constrainedToSize:constraintSize lineBreakMode:UILineBreakModeWordWrap];

    return labelSize.height + 20;
}

Answer

Jesse Black picture Jesse Black · Jan 17, 2012

You can look into the fontNamesForFamilyName: method.

Specifically for Helvetica there are these families

NSLog(@"%@", [UIFont fontNamesForFamilyName:@"Helvetica"]);
"Helvetica-LightOblique",
Helvetica,
"Helvetica-Oblique",
"Helvetica-BoldOblique",
"Helvetica-Bold",
"Helvetica-Light"