uibutton - ios - set / unset button background color -
uibutton - ios - set / unset button background color -
using method:
- (ibaction)buttonclicked:(id)sender { mybutton.backgroundcolor = [uicolor blackcolor]; }
i can set black color mybutton. how can toggle between 2 color, each time button clicked?
tx in advance
in h file initialize bool property
@property (nonatomic, assign) bool mybool;
in m file set next line in viewdidload
self.mybool = yes;
then in ibaction,
- (ibaction)buttonclicked:(id)sender { if (self.mybool) { self.button.backgroundcolor = [uicolor blackcolor]; self.mybool = no; } else { self.button.backgroundcolor = [uicolor blackcolor]; self.mybool = yes; } }
colors uibutton
Comments
Post a Comment