views:

1099

answers:

1

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?

+4  A: 

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.

pgb
It returns to normal after tapping/selecting. This is what I have done w/o IB. [favButton setImage:favOff forState:UIControlStateNormal]; [favButton setImage:favOn forState:UIControlStateHighlighted]; [favButton setImage:favOn forState:UIControlStateSelected]; [favButton setBackgroundColor:[UIColor clearColor]]; [self.view addSubview:favButton];
hecta
Ok "setSelected" was the property I was looking for, thanks
hecta