I'm trying to change font size of UISegementedControl
in tvOS (if that helps). By default, the font is huge! I have been able to reduce it like so
let switchAttributes = [NSForegroundColorAttributeName: UIColor.lightGray, NSFontAttributeName: UIFont.systemFont(ofSize: 28)]
segementedControl.setTitleTextAttributes(switchAttributes, for: .normal)
but this seems to affect only its .normal
state. All the other states do not appear to be affected by this, nor by specifying their text attributes:
segementedControl.setTitleTextAttributes(switchAttributes, for: .selected) // No effect
segementedControl.setTitleTextAttributes(switchAttributes, for: .focused) // No effect
Here you can see how huge focused and selected states are
I know this has been answered before and my code worked fine before, but since tvOS 10 update everything broke and I haven't found any way to fix this issue. Perhaps it's just Apple's bug, but maybe I'm missing something?
Any help is appreciated.
Try this:
let font = UIFont.boldSystemFont(ofSize: 8.0)
let attributes = [ NSFontAttributeName : font ]
segmentedControl.setTitleTextAttributes(attributes, for: .selected)
Worked for me when I tested it