Change text color of UISegmentedControl

There's no way to set the custom color of selected segment title in UISegmentedControl. The UIControlState in forState: used to set the attributes of segment text for normal and selected state.

From Your Code :

[[UIsegmentControl.subviews objectAtIndex:segment.selectedSegmentIndex] setTintColor:[UIColor redColor]];

Try This Code:

[segmnt_cntrl setTitleTextAttributes:@{NSFontAttributeName:[UIFont fontWithName:@"Arial" size:16.0],
                                                          NSForegroundColorAttributeName:[UIColor redColor],
                                                          NSShadowAttributeName:shadow}
                                                         forState:UIControlStateNormal];

Replace the segmnt_cntrl with your object of Segment Cotrol. Try this , It might helps you to achieve your over all goal.

Thanks


If you need to change the text color of the highlighted segment in iOS 7, here is a solution (took me awhile to find, but thanks to this post):

[[UISegmentedControl appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor colorBlack]} forState:UIControlStateSelected];

With references to @i-- Answer

Updated Swift 5

UISegmentedControl.appearance().setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.red], for: .selected)

Updated Swift 4.1

UISegmentedControl.appearance().setTitleTextAttributes([NSAttributedStringKey.foregroundColor: UIColor.red], for: .selected)

Swift 3.1

UISegmentedControl.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.red as Any], for: .selected)

For Earlier Swift Version:

UISegmentedControl.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.red], for: .selected)