i'm using the following code to set the color of each segment in UISegmentedControl.
for (int i = 0; i < [self.controlStatus numberOfSegments]; i++)
{
NSArray *ar=self.controlStatus.subviews;
if ([[self.controlStatus titleForSegmentAtIndex:i] isEqualToString:@"ON"])
{
[[self.controlStatus.subviews objectAtIndex:i] setTintColor:[UIColor greenColor]];
}
else if ([[self.controlStatus titleForSegmentAtIndex:i] isEqualToString:@"OFF"])
{
[[self.controlStatus.subviews objectAtIndex:i] setTintColor:[UIColor orangeColor]];
}
else if ([[self.controlStatus titleForSegmentAtIndex:i] isEqualToString:@"HIDE"])
{
[[self.controlStatus.subviews objectAtIndex:i] setTintColor:[UIColor redColor]];
}
}
}
But i'm not getting the color as i need in corresponding segment. Sometimes the colors are as follows:
1st segment - GREEN
2nd segment - ORANGE
3rd segment - RED
But at some stage when i navigate to other pages and come back, the color changes:
1st segment - RED
2nd segment - ORANGE
3rd segment - GREEN
Can anyone give me an idea about whats happening here.
Aucun commentaire:
Enregistrer un commentaire