Proud Member Proud Member - 1 year ago 185
iOS Question

Is there a medium weight font between -systemFontOfSize: and -boldSystemFontOfSize:?

-systemFontOfSize is too thin, and boldSystemFontOfSize too thick. I need something inbetween.

When I create a UIFont like this:

[UIFont boldSystemFontOfSize:14];

then the debugger prints this font info:

font-family: ".Helvetica NeueUI"; font-weight:
bold; font-style: normal; font-size: 14px

Sometimes fonts have a medium font weight. How can I create a font of this type but with a medium weight?

Answer Source

Calling NSLog(@"%@", [UIFont fontNamesForFamilyName:@"Helvetica Neue"]); prints all available font styles for Helvetica Neue, among them is HelveticaNeue-Medium which sounds like the one you want:

UIFont *font = [UIFont fontWithName:@"HelveticaNeue-Medium" size:14.0f];

If you want to make sure that the font also changes when the system font changes (eg. like it did with retina devices from Helvetica to Helvetica Neue) you could first get the system font and then take its familyName and pointSize to retrieve one with medium weight using + fontNamesForFamilyName and then + fontWithName:size:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download