I am dynamically create UIlabels and for the first label I use Bold style.
for (int i = 0; i < vehicles.count; ++i) {
CGRect labelRect = CGRectMake(i * (self.frame.size.width / vehicles.count),
3, self.frame.size.width / vehicles.count,
13);
UILabel *label = [[UILabel alloc] initWithFrame:labelRect];
label.textColor = thumbColor;
label.textAlignment = NSTextAlignmentCenter;
label.text = vehicles[i].vehicleClass;
UIFont *labelFont;
if (i == 0) {
labelFont = [UIFont fontWithName:@"Avenir Next-Bold" size:9.0];
} else {
labelFont = [UIFont fontWithName:@"Avenir Next" size:9.0];
}
label.font = labelFont;
[vehiclesLabels addObject:label];
[self addSubview:label];
}
But it draw like this
Why the first label is larger?
For "Avenir Next" family fonts you must use these names:
AvenirNext-MediumItalic, AvenirNext-Bold, AvenirNext-UltraLight, AvenirNext-DemiBold, AvenirNext-HeavyItalic, AvenirNext-Heavy, AvenirNext-Medium, AvenirNext-Italic, AvenirNext-UltraLightItalic, AvenirNext-BoldItalic, AvenirNext-Regular, AvenirNext-DemiBoldItalic
Change Avenir Next-Bold to AvenirNext-Bold, and Avenir Next to AvenirNext-Regular
Just you need to change the below line of code.
labelFont = [UIFont fontWithName:@"AvenirNextCondensed-Bold" size:9.0];
For all of the font family name checking use following code for that.
NSArray *familyNames = [[NSArray alloc] initWithArray:[UIFont familyNames]];
NSArray *fontNames;
NSInteger indFamily, indFont;
for (indFamily=0; indFamily<[familyNames count]; ++indFamily)
{
NSLog(@"Family name: %@", [familyNames objectAtIndex:indFamily]);
fontNames = [[NSArray alloc] initWithArray:
[UIFont fontNamesForFamilyName:
[familyNames objectAtIndex:indFamily]]];
for (indFont=0; indFont<[fontNames count]; ++indFont)
{
NSLog(@" Font name: %@", [fontNames objectAtIndex:indFont]);
}
}
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