MattLoszak
MattLoszak

Reputation: 585

Helvetica Neue Light,iOS

Surprisingly I can't seem to find another question on this... sorry if I'm missing something obvious.

I'm trying to use Helvetica Neue Light programatically in my iPhone app. It seems that the system doesn't have this built in, which seems strange.

Is this the case? Does this particular font need to be added manually?

Ideally I'd like to edit this line of code to accomplish this:

myLabel.font = [UIFont fontWithName:@"HelveticaNeue" size: 32];

Upvotes: 30

Views: 37891

Answers (4)

aashish tamsya
aashish tamsya

Reputation: 4959

UPDATE FOR SWIFT 3

For the past few month, swift approach towards init has changed, I would recommend not to use init in Swift 3

label.font = UIFont(name: "HelveticaNeue-Light", size: 17.0)

Objective- C :

[label setFont:[UIFont fontWithName:@"HelveticaNeue-Light" size:17.0f]];

Swift 2.2 :

label.font = UIFont.init(name: "HelveticaNeue-Light", size: 17.0)

UPDATE :

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

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

Objective-C :

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

Swift 2.2 :

UILabel.appearance().font = UIFont.init(name: "HelveticaNeue-Thin", size: 32.0)

To set font to particular UILabel use this code :

Objective-C :

[labelName setFont:[UIFont fontWithName:@"HelveticaNeue-Thin" size:15.0f]];

Swift 2.2 :

label.font = UIFont.init(name: "HelveticaNeue-Light", size: 17.0)

Upvotes: 7

AFTAB MUHAMMED KHAN
AFTAB MUHAMMED KHAN

Reputation: 2186

I have one suggestion if you like to use UIFont please print all the font names. so in future you will always get correct font name.

You just need to paste method somewhere in you class and you will get the list of all system fonts

-(void)fontNames{

    NSArray *familyNames = [UIFont familyNames];
    [familyNames enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop){
        NSLog(@"* %@",obj);
        NSArray *fontNames = [UIFont fontNamesForFamilyName:obj];
        [fontNames enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop){
            NSLog(@"--- %@",obj);
        }];
    }];  

}

Upvotes: 0

Ahmed Z.
Ahmed Z.

Reputation: 2337

Here is a link where all the supported fonts are available for iOS.

HelveticaNeue is supported in iOS and its Keyword is "HelveticaNeue"

Upvotes: 6

rckoenes
rckoenes

Reputation: 69499

The font name you used is incorrect, try:

Objective-C

myLabel.font = [UIFont fontWithName:@"HelveticaNeue-Light" size:32.0f];

Swift

myLabel.font = UIFont(name: "HelveticaNeue-Light", size: 32.0)

On iOS Fonts you will find the full list of fonts and their names.

Upvotes: 118

Related Questions