How do I support Dynamic Type in UILabel
and UITextView
in iOS 7? I'm adapting one of our projects for iOS 7 and would like to support this accessibility feature. I can't find the specific how to tutorial on it on Apple's iOS Developer site.
相关问题
- Get the NSRange for the visible text after scroll
- Extracting from a Union Type when some have identi
- Mathjax not rendering TEX formulas dynamically fro
- Haskell: What is the differrence between `Num [a]
- How to access with ctypes to functions returning c
相关文章
- Angular Material Stepper causes mat-formfield to v
- How do I get from a type to the TryParse method?
- Xcode: Is there a way to change line spacing (UI L
- didBeginContact:(SKPhysicsContact *)contact not in
- Adding TapGestureRecognizer to UILabel in Swift
- Java Generics: How to specify a Class type for a g
- ios7 new pan gesture to go back in navigation stac
- IOS UICollectionview Dynamically change Cell's
If you use the new
UIFont
methods then you're pretty much there - you just need to add the observer to listen for changes.Rather than setting a specific font size, you should use the
preferredFontForTextStyle:
and related methods when styling your labels (if you're using Interface Builder you can select a style directly in the inspector). For example:self.label.font = [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline];
Once you've done that you should listen for the
UIContentSizeCategoryDidChangeNotification
. When you receive this notification you should layout your labels to support the newly selected size (if you're using autolayout this is normally as simple as sendinginvalidateIntrinsicContentSize
to your views).If you're looking for official documentation then take a look at the Text Programming Guide.
In Swift 3 and iOS 10 you can use
See this excellent post for more information, especially how to support pre iOS 10.