19

I am creating UILabel, for the label i can set the font name as HelveticaNeue Regular, Light, UltraLight etc, But i unable to set the font name as HelveticaNeue Thin, it is not working as expected. I did like,

label.font = [UIFont fontWithName:@"HelveticaNeue-Thin" size:16];

Also i have searched on Google didnt got any solution. How to fix this issue? Thanks.

Surfer
  • 1,370
  • 3
  • 19
  • 34

4 Answers4

26

This font is bundled with iOS 7, so if you're targeting iOS 7 and above your

label.font = [UIFont fontWithName:@"HelveticaNeue-Thin" size:16.0f];

will work.

However if you are targeting iOS 6.1 and below you'll need to embed the font

ncremins
  • 9,140
  • 2
  • 25
  • 24
19

Updated answer to support swift

    let font = UIFont(name: "HelveticaNeue-Thin", size: 16.0)!
RiceAndBytes
  • 1,286
  • 10
  • 21
3
UIFontDescriptor *helveticaNeueFamily =
    [UIFontDescriptor fontDescriptorWithFontAttributes:
        @{ UIFontDescriptorFamilyAttribute: @"Helvetica Neue" }];
NSArray *matches =
    [helveticaNeueFamily matchingFontDescriptorsWithMandatoryKeys: nil];

The matchingFontDescriptorsWithMandatoryKeys: method as shown returns an array of font descriptors for all the Helvetica Neue fonts on the system, such as HelveticaNeue, HelveticaNeue-Medium, HelveticaNeue-Light, HelveticaNeue-Thin, and so on.

You can modify the fonts returned by preferredFontForTextStyle: by applying symbolic traits, such as bold, italic, expanded, and condensed. You can use font descriptors to modify particular traits, as shown in Listing 9-2.

referenced by apple

or

this font you can't apply directly.

so you can customize your font

How to use custom fonts in iPhone SDK?

Community
  • 1
  • 1
codercat
  • 22,873
  • 9
  • 61
  • 85
1

This has worked for me. Write this code below your label declarations.

It sets all the UILabel under a function with same font.

[[UILabel appearance]setFont:[UIFont fontWithName:@"HelveticaNeue-Thin" size:32.0f]];

To set font to particular UILabel use this code :

[labelName setFont:[UIFont fontWithName:@"HelveticaNeue-Thin" size:15.0f]];
aashish tamsya
  • 4,903
  • 3
  • 23
  • 34
  • This does seem to work for me too, however googling suggests that it shouldn't work, confused. – Jules Jun 20 '15 at 19:14