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
2010-02-12 21:19:56
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
2010-02-12 21:24:48
Ok "setSelected" was the property I was looking for, thanks
hecta
2010-02-12 21:43:44