In iOS7 there are new API\'s for getting a font that is automatically adjusted to the text size the user has set in their preferences.
It looks something like this to
This is how I do it in Swift. I like this because it's more general, it only requires one table, and it should work well with any font. First I wrote a generalized multiplier (in a getter).
var fontSizeMultiplier : CGFloat {
get {
switch UIApplication.sharedApplication().preferredContentSizeCategory {
case UIContentSizeCategoryAccessibilityExtraExtraExtraLarge: return 23 / 16
case UIContentSizeCategoryAccessibilityExtraExtraLarge: return 22 / 16
case UIContentSizeCategoryAccessibilityExtraLarge: return 21 / 16
case UIContentSizeCategoryAccessibilityLarge: return 20 / 16
case UIContentSizeCategoryAccessibilityMedium: return 19 / 16
case UIContentSizeCategoryExtraExtraExtraLarge: return 19 / 16
case UIContentSizeCategoryExtraExtraLarge: return 18 / 16
case UIContentSizeCategoryExtraLarge: return 17 / 16
case UIContentSizeCategoryLarge: return 1.0
case UIContentSizeCategoryMedium: return 15 / 16
case UIContentSizeCategorySmall: return 14 / 16
case UIContentSizeCategoryExtraSmall: return 13 / 16
default: return 1.0
}
}
}
Then I update the font (e.g., in the observer) using a UIFontDescriptor
like this:
textView.font = UIFont(descriptor: fontDescriptor!, size: fontDescriptor!.pointSize * fontSizeMultiplier)