I need to implement a custom switch in a project. Currently what I have found is that we cannot alter with UISwitch in way to implement as shown in below image. I've followed posts and googled through stackoverflow and other blogs but didn't found a solution as desired. One way is to go with UISegmented control as in this post, but that too doesn't solves my problem.
Thanks in advance for any help
As gasparuff says, you can also do it with a UIButton, just set the images:
[button setImage:[UIImage imageNamed:@"image_on"] forState:UIControlStateSelected];
[button setImage:[UIImage imageNamed:@"image_off"] forState:UIControlStateNormal];
and when it's tapped just toggle the selected property.
- (void) buttonTap {
button.selected = !button.selected;
}
Which will change the images automatically.