Last active
August 29, 2015 13:56
-
-
Save ritesh-fueled/9150502 to your computer and use it in GitHub Desktop.
Label or Text Dynamic Type
This file contains 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
-(void) doDynamicTypeThings{ | |
self.someHeadline.font = [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline]; | |
self.someBodyTextLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody]; | |
} | |
- (void)viewWillAppear:(BOOL)animated{ | |
[super viewWillAppear:animated]; | |
[[NSNotificationCenter defaultCenter] addObserver:self | |
selector:@selector(preferredContentSizeChanged:) | |
name:UIContentSizeCategoryDidChangeNotification | |
object:nil]; | |
[self doDynamicTypeThings]; | |
} | |
- (void)preferredContentSizeChanged:(NSNotification *)notification{ | |
[self doDynamicTypeThings]; | |
[self.view setNeedsLayout]; | |
} | |
-(void) viewWillDisappear:(BOOL)animated{ | |
[super viewWillDisappear:animated]; | |
[[NSNotificationCenter defaultCenter] removeObserver:self]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment