Skip to content

Commit

Permalink
Make NumericPicker example respond to changes in dynamic fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
MattLewin committed Sep 19, 2018
1 parent 09c5265 commit b455756
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions NumericPicker-Example/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ class ViewController: UIViewController {
codeNumericPicker.locale = Locale(identifier: "de-DE")
codeNumericPicker.addTarget(self, action: #selector(codeValueChanged), for: .valueChanged)
codePickerStack.addArrangedSubview(codeNumericPicker)

NotificationCenter.default.addObserver(self,
selector: #selector(contentSizeCategoryChanged(_:)),
name: NSNotification.Name.UIContentSizeCategoryDidChange,
object: nil)

}

override func viewWillAppear(_ animated: Bool) {
Expand All @@ -68,4 +74,8 @@ class ViewController: UIViewController {
ibPickerValue.text = sender.displayString
}

@objc func contentSizeCategoryChanged(_ notification: Notification) {
ibNumericPicker.font = UIFont.preferredFont(forTextStyle: .body)
codeNumericPicker.font = UIFont.preferredFont(forTextStyle: .body)
}
}

0 comments on commit b455756

Please sign in to comment.