Skip to content

Instantly share code, notes, and snippets.

@ritesh-fueled
Last active August 29, 2015 13:56
Show Gist options
  • Save ritesh-fueled/9150502 to your computer and use it in GitHub Desktop.
Save ritesh-fueled/9150502 to your computer and use it in GitHub Desktop.
Label or Text Dynamic Type
-(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