raddaoui
raddaoui

Reputation: 105

selected SegmentedControl's font separately

I am developing an iOS app using swift, and i would like to change the selected SegmentedControl's font, only the selected one, i have found already how to change the font for all the segments but i am looking for a way to do it separately, like for example bold only for the selected segment.

this is how to do it for all segments in UISegmentedControl :

let attr = NSDictionary(object: UIFont(name: "OpenSans", size: 12.0)!, forKey: NSFontAttributeName as NSCopying)
UISegmentedControl.appearance().setTitleTextAttributes(attr as [NSObject : AnyObject] , for: .normal)

Upvotes: 0

Views: 43

Answers (1)

inokey
inokey

Reputation: 6170

You can use setTitleTextAttributes for UIControlState just use not .normal but .selected

Upvotes: 2

Related Questions