Last active
March 17, 2019 04:00
-
-
Save laevandus/02e5a8e42c4967fd6d6048317a0c9f1f to your computer and use it in GitHub Desktop.
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
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