Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Appearance Proxy in Swift (iOS)

Tags:

ios

swift

ios8

Has anyone tried using the appearance proxy in swift yet?

This syntax doesn't work, has anyone figured out how to set title text attributes on controls like segmentedControl or UITabBar? I think I am close

segmentedControl.titleTextAttributesForState(UIControlState.Normal) = 
NSDictionary(objects: [UIFont(name: fontFamilyRegular, size: 16.0)], 
forKeys: [NSFontAttributeName])
like image 654
DBoyer Avatar asked Jun 03 '14 14:06

DBoyer


1 Answers

This should do it:

segmentedControl.setTitleTextAttributes([
    NSFontAttributeName: UIFont(name: "Helvetica", size: 16.0)!,
    NSForegroundColorAttributeName: UIColor.blueColor()
    ], forState: UIControlState.Normal)
like image 60
Cezar Avatar answered Oct 09 '22 13:10

Cezar