iPhone UIButton with UISwitch functionality

Is there either a way to implement UISwitch with custom graphics for the switch-states? Or as an alternative the other way round, an UIButton with UISwitch functionality?


UIButton already supports a "switch" functionality.

Just set a different image in Interface Builder for the "Selected State Configuration", and use the selected property of UIButton to toggle its state.


set the image to show on selected state:

[button setImage:[UIImage imageNamed:@"btn_graphics"] forState:UIControlStateSelected];

and then on touch up inside selector, set:

button.selected = YES;

if you want this to cancel another button's selection, set:

otherButton.selected = NO;