1

I have a label named label. Now, I am initializing the font of the label like this:

label.font = UIFont(name: fontFamily!, size: 32.0)

Now, when I am printing the label.font, this is the output:

<UICTFont: 0x79694a70> font-family: ".HelveticaNeueInterface-Regular"; font-weight: normal; font-style: normal; font-size: 17.00pt

The font-size is always 17.00pt whatever size I pass to UIFont. What can be the error? Or am I missing something?

Edit:

After checking everything, it seemed that the name of font that I was passing was wrong because of which it was creating a default UIFont() instance. If someone has this problem, may check if he/she is passing the correct name or not.

Thanks

0

2 Answers 2

1

Try it like this:

let font = UIFont(name: "Helvetica", size: 32.0)
label.font = font

I think that implicitly unwrapped optional is causing issues. - the default system font is size 17, Helvetica Neue.

Sign up to request clarification or add additional context in comments.

1 Comment

It seems it is because I am passing the font name as Helvetica Neue LT Std Light-Normal
0

Try this

yourLable.text = "Your text will be here"

yourLable.textAlignment = NSTextAlignment.Right
yourLable.textAlignment = .Right

yourLable.textColor = UIColor.redColor()
yourLable.shadowColor = UIColor.blackColor()
yourLable.font = UIFont(name: "HelveticaNeue", size: CGFloat(22))

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.