Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set font name of UILabel as HelveticaNeue Thin in iOS?

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.

like image 863
Surfer Avatar asked Feb 28 '14 09:02

Surfer


People also ask

How do I change the font of a label in iOS Swift?

To change the font or the size of a UILabel in a Storyboard or . XIB file, open it in the interface builder. Select the label and then open up the Attribute Inspector (CMD + Option + 5). Select the button on the font box and then you can change your text size or font.


2 Answers

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

like image 113
ncremins Avatar answered Oct 23 '22 14:10

ncremins


Updated answer to support swift

    let font = UIFont(name: "HelveticaNeue-Thin", size: 16.0)!
like image 40
RiceAndBytes Avatar answered Oct 23 '22 15:10

RiceAndBytes