Well two possibilities:
1) Create a button and a given background image as the only point of the UISegmentedControl
If your SegmentedControl is a class variable, just replace @property
@property (nonatomic, retain) IBOutlet UIButton *button;
In the viewDidLoad function add the following
-(void) viewDidLoad { [super viewDidLoad]; ... self.button = [UIButton alloc] init]; [self.button setBackgroundImage:[UIImage imageNamed:@"segmentedDot.png"] forState:(UIControlState)UIControlStateNormal]; }
2) Set the number of segments to three of your UISegmentedControl, and then set the width to 20 - now only the dot in the middle will be displayed. Do not forget that if the user interacts with the UISegmentedControl, set currentElement to the second segment again, otherwise the dot will be light gray, not white.
3) Place a button or small view on top of the unwanted second point of the UISegmentedControl in the InterfaceBuilder. Make sure the background color is even. When you use the button, the user interaction state in the attribute inspector is disabled to disable it. As a type, I would choose "custom", since you will not have any borders in your button;) Now the man is again sure that the first point is always the active element.
However, I think the solution should be the way you should go, because Apple thought something about it when they turned off 1-dot-SegmentedControl. Since you are using the control as a button, the element you are looking for fpr should be a button .;)
user413280
source share