Make a segment of a segmented control invisible

Can I make one segment of a segmented control invisible?

+7
source share
3 answers

Although there seems to be no way to hide a segment in a segment control, you can remove a segment from a segment control using the removeSegmentAtIndex:animated: method. You need either insertSegmentWithImage:atIndex:animated: or insertSegmentWithTitle:atIndex:animated: to insert the segment again.

Instead of hiding / showing a segment, you might consider enabling / disabling it using the setEnabled:forSegmentAtIndex: method.

+11
source

You cannot hide it, but you can make its width very small , which will make it invisible to the user. It must be> 0, because 0 = automatic width.

 [yourSegmentedControl setWidth:0.1 forSegmentAtIndex:1]; 

To be safe, also turn it off to reduce the chance of a choice to zero.

 [mapTypeSC setEnabled:NO forSegmentAtIndex:1]; 
+10
source

If you need only one segment, then why use segment management, you can directly use the button.

0
source

All Articles