Skip to content

Instantly share code, notes, and snippets.

@abbeyjackson
Created November 2, 2015 16:03
Show Gist options
  • Save abbeyjackson/7ff2c6a3d0b7553e4198 to your computer and use it in GitHub Desktop.
Save abbeyjackson/7ff2c6a3d0b7553e4198 to your computer and use it in GitHub Desktop.
Supporting dynamic text and preferred font size
// configure labels:
- (void)configureView
{
self.textSizeLabel.text = [[UIApplication sharedApplication] preferredContentSizeCategory];
self.headlineLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline];
self.subheadLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline];
self.bodyLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
self.caption1Label.font = [UIFont preferredFontForTextStyle:UIFontTextStyleCaption1];
self.caption2Label.font = [UIFont preferredFontForTextStyle:UIFontTextStyleCaption2];
self.footnoteLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleFootnote];
}
// listen for the setting change:
- (void)viewDidLoad
{
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(didChangePreferredContentSize:)
name:UIContentSizeCategoryDidChangeNotification
object:nil];
}
// change things when the settings change:
- (void)didChangePreferredContentSize:(NSNotification *)notification
{
[self configureView];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment