Extension for UISegmentedControl
for setting Font Size.
extension UISegmentedControl {
@available(iOS 8.2, *)
func setFontSize(fontSize: CGFloat) {
let normalTextAttributes: [NSObject : AnyObject]!
if #available(iOS 9.0, *) {
normalTextAttributes = [
NSFontAttributeName: UIFont.monospacedDigitSystemFontOfSize(fontSize, weight: UIFontWeightRegular)
]
} else {
normalTextAttributes = [
NSFontAttributeName: UIFont.systemFontOfSize(fontSize, weight: UIFontWeightRegular)
]
}
self.setTitleTextAttributes(normalTextAttributes, forState: .Normal)
}
}