Skip to content

Instantly share code, notes, and snippets.

@mertsimsek
Last active August 29, 2015 14:17
Show Gist options
  • Save mertsimsek/8d6029b7f6600e11f3a9 to your computer and use it in GitHub Desktop.
Save mertsimsek/8d6029b7f6600e11f3a9 to your computer and use it in GitHub Desktop.
Dynamic text size for iOS
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 20)];
/*
set your label's font to the suitable one of the below to make your text size dynamic.
*/
label.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
label.font = [UIFont preferredFontForTextStyle:UIFontTextStyleCaption1];
label.font = [UIFont preferredFontForTextStyle:UIFontTextStyleCaption2];
label.font = [UIFont preferredFontForTextStyle:UIFontTextStyleFootnote];
label.font = [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline];
label.font = [UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment