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]; 

4 Answers

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.

1

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) 

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

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

1

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); }]; }]; } 
1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.