0

I am using this for changing the text color of text of segmented control but its color is not getting changed in UIControlStateNormal. I have to kept the same color for both states.

NSDictionary *highlightedAttributes = [NSDictionary 
    dictionaryWithObject:[UIColor blueColor] forKey:UITextAttributeTextColor];
[self.segmentController
    setTitleTextAttributes:highlightedAttributes forState:UIControlStateSelected];
Mundi
  • 77,414
  • 17
  • 110
  • 132
Ankur
  • 98
  • 2
  • 13

2 Answers2

0

You have to set any attributes explicitly for the normal state (UIControlStateNormal) as well.

Mundi
  • 77,414
  • 17
  • 110
  • 132
0

Try this:

NSDictionary *textAttributes = @{NSFontAttributeName: [UIFont systemFontOfSize:13],
                                 UITextAttributeTextColor: UIColorFromRGB(0x93938D),
                                 UITextAttributeTextShadowColor: [UIColor clearColor]
                                 };
[self.segmentController setTitleTextAttributes:textAttributes forState:UIControlStateNormal];
[self.segmentController setTitleTextAttributes:textAttributes forState:UIControlStateSelected];
nmh
  • 2,477
  • 1
  • 13
  • 27