Author Topic: How can I change the text color of a segmented control in Swift?  (Read 26119 times)


  • Administrator
  • *****
  • Posts: 719
    • View Profile
To change the text color of all segmented controls in your app, call setTitleTextAttributes on the UISegmentedControl's appearance proxy. For example:
Code: [Select]
UISegmentedControl.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.redColor()], forState: UIControlState.Selected)
To change the text color of an individual segmented control, call setTitleTextAttributes directly on the segmented control object:

Code: [Select]
self.segmentedControl.setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.redColor()], forState: UIControlState.Selected)
All the best!
Kevin McNeish
Author of Learn to Code in Swift: