iOS 10.3 crashes on UISegmentedControl
's setTitleTextAttributes
method.
Question:
- What is the reason for the crash?
- What is the solution?
Note: Have already reported this issue to apple, but haven't yet heard from them. https://openradar.appspot.com/31448227
Sample Code:
class ViewController: UIViewController {
@IBOutlet private weak var segmentedControl: UISegmentedControl!
override func viewDidLoad() {
super.viewDidLoad()
//Crash!
segmentedControl.setTitleTextAttributes([UIFont.systemFont(ofSize: 14.0) : NSFontAttributeName], for: .normal)
}
}
EDIT
As @vedian pointed out, it should be [key : value]
and not the other way around, but the above code doesn't crash on iOS versions below 10.3.