Created
November 2, 2015 16:03
-
-
Save abbeyjackson/7ff2c6a3d0b7553e4198 to your computer and use it in GitHub Desktop.
Supporting dynamic text and preferred font size
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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