There are a dozen answers to how to set the font of a UISegmentedControl
, but I want to determine what font is being used, without having been manually set.
override func viewDidLoad() {
super.viewDidLoad()
let s = segmentedControl.state // normal
let ta1 = segmentedControl.titleTextAttributes(for: .normal) // nil
let ta2 = UISegmentedControl.appearance().titleTextAttributes(for: .normal) // nil
}
Apple's API documentation is of no insight.
The ultimate purpose is to use the font to calculate the size of the string, and compare to the segment size (if I can get that) and determine if the title is being truncated. Similar to How do I check if UILabel is truncated?