Skip to content

Instantly share code, notes, and snippets.

@marinofelipe
Last active April 8, 2019 03:22
Show Gist options
  • Select an option

  • Save marinofelipe/8eef4cb83f8d3eda08843f0232d26595 to your computer and use it in GitHub Desktop.

Select an option

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
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