Reputation: 23
I'm trying to change the style of the text in my UISegmentedControl. I want to use the system font but the "Light" style of it. I understand how exactly to do this in terms of the line of code, literally just need the string to establish the Light system font. I have tried "System-Light" and some others but it keeps resulting in an error, yet any other (custom) fonts work fine.
i.e. :
let attr = NSDictionary(object: UIFont(name: "WHAT GOES IN HERE????", size: 13.0)!, forKey: NSFontAttributeName) UISegmentedControl.appearance().setTitleTextAttributes(attr as [NSObject : AnyObject], forState: .Normal)
Any ideas?
Upvotes: 0
Views: 515
Reputation: 166
To create a system font, instead of the standard UIFont constructor use the class method UIFont.systemFontOfSize(fontSize, weight)
.
For the light font use the UIFontDescriptor constant UIFontWeightLight
.
For reference see UIFont and UIFontDescriptor class references.
Upvotes: 0