Skip to content

Instantly share code, notes, and snippets.

@laevandus
Last active March 17, 2019 04:00
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
extension UIFont.TextStyle {
public static let largeTitle: UIFont.TextStyle
public static let title1: UIFont.TextStyle
public static let title2: UIFont.TextStyle
public static let title3: UIFont.TextStyle
public static let headline: UIFont.TextStyle
public static let subheadline: UIFont.TextStyle
public static let body: UIFont.TextStyle
public static let callout: UIFont.TextStyle
public static let footnote: UIFont.TextStyle
public static let caption1: UIFont.TextStyle
public static let caption2: UIFont.TextStyle
}
let font = UIFont.preferredFont(forTextStyle: style)
// Automatically update font size when user changes preferred text size or accessibility text sizes.
label.adjustsFontForContentSizeCategory = true
label.font = font
// And the same behavior with buttons without attributed title.
button.titleLabel?.adjustsFontForContentSizeCategory = true
button.titleLabel?.font = font
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment