Question

I've got UISegmentedControl as part of navigation bar for swapping viewcontrollers - I need to be able to disable some segment on various conditions. The problem is that iOS (7 in my case) is messing up with segment font when the segment is disabled - instead of changing alpha to 0.5 as normal it changes color of the font to dark grey so it's almost unreadable on black bar. I've tried to create workaround setEnable which would just change aplha but as soon as I use setUserInteractionEnabled to NO, iOS will change the font color automatically again.

Any ideas how to get around this issue?

Was it helpful?

Solution

You need to set the title attributes for the disabled state:

NSDictionary *attrs = @{ UITextAttributeTextColor : [UIColor purpleColor] };
[segmentedControl setTitleTextAttributes:attrs forState:UIControlStateDisabled];

Obviously you should replace the purple color with the color you want when the segment is disabled.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top