Change the color of selected segment control
I'd recommend to create the two colors outside of your condition, makes your code a bit smaller. Then you can use a foreach to iterate over your segments :
UIColor *selectedColor = [UIColor colorWithRed: 98/255.0 green:156/255.0 blue:247/255.0 alpha:1.0];UIColor *deselectedColor = [UIColor colorWithRed: 54/255.0 green:52/255.0 blue:48/255.0 alpha:1.0];for (UIControl *subview in [SegmentRound subviews]) { if ([subview isSelected]) [subview setTintColor:selectedColor]; else [subview setTintColor:deselectedColor]; }
check out this one
-(IBAction)segmentBtnPressed:(UISegmentedControl*)sender{for (int i=0; i<[sender.subviews count]; i++) { if ([[sender.subviews objectAtIndex:i]isSelected] ) { UIColor *tintcolor=[UIColor colorWithRed: 98/255.0 green:156/255.0 blue:247/255.0 alpha:1.0]; [[sender.subviews objectAtIndex:i] setTintColor:tintcolor]; } else{ UIColor *tintcolor=[UIColor colorWithRed:127.0/255.0 green:161.0/255.0 blue:183.0/255.0 alpha:1.0]; [[sender.subviews objectAtIndex:i] setTintColor:tintcolor]; }}}
Also you can check out more answers here UISegmentedControl selected segment color
I hope you can simply change the TintColor of Segment Control. It works perfectly for me.