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

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -