3

While using Interface builder & iOS7 UIFontTextStyleHeadline I set my headline label to UIFontTextStyleHeadline

(I guess it can be done also with the following code:)

myHeadlineTextLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline];

Q: this works well, yet I would like to have the same functionality only using HelveticaNeue-Thin

just as an example:

titleCustomLabel.font = [UIFont fontWithName:@"HelveticaNeue-Thin" size:(**Dynamic font size as the user defined in his setting**)];

what would be an elegant way to do so?

chewy
  • 8,207
  • 6
  • 42
  • 70

1 Answers1

5

UIFont has the fontSize property. You can make use of that.

titleCustomLabel.font = [UIFont fontWithName:@"HelveticaNeue-Thin" size:[UIFont preferredFontForTextStyle:UIFontTextStyleHeadline].pointSize];

(don't use fontSize at the end)

chewy
  • 8,207
  • 6
  • 42
  • 70
Ramaraj T
  • 5,184
  • 4
  • 35
  • 68
  • excellent Suresh, thanks. - can you just fix the answer to pointSize to be super correct? – chewy Oct 21 '13 at 13:51