Last active
April 8, 2019 03:22
-
-
Save marinofelipe/8eef4cb83f8d3eda08843f0232d26595 to your computer and use it in GitHub Desktop.
Blog post / Dynamic Type - Shows how to listen to content size category changes above and under iOS 10
This file contains hidden or 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
| private func adjustForContentSizeCategoryChanges() { | |
| if #available(iOS 10.0, *) { | |
| label.adjustsFontForContentSizeCategory = true | |
| } else { | |
| NotificationCenter.default.addObserver(self, | |
| selector: #selector(self.didChangeContentSizeCategory), | |
| name: UIContentSizeCategory.didChangeNotification, | |
| object: nil) | |
| } | |
| } | |
| @objc func didChangeContentSizeCategory() { | |
| label.font = UIFont.preferredFont(forTextStyle: .body) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment