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

Popular posts from this blog

maven fortify plugin : Unable to load build session with ID XXXXX .. See log file for more details -

c# - Primavera WebServices does not return any data -

android - Display emoji panel with genymotion - keyboard/touch input? -