Search code examples
objective-cios6fontsfont-family

setting font family in font (ignoring size)


What I was trying is set font size and font family separately due to some reasons.

For setting size I used

[addressLabel setFont:[UIFont systemFontOfSize:12.0]];

However for family name I am not finding how to do that.. Any idea how to get that?


Solution

  • You need more than just the font family, you need the font name. Once you have a font name, if you want to update the label's font to the new font with the same size, you can do:

    UIFont *oldFont = addressLabel.font
    UIFont *newFont = [UIFont fontWithName:someName size:oldFont.pointSize];
    addressLabel.font = newFont;