objective c - change a backgroundcolor of button inside a view that has a UITapGestureRecognizer and buttons -
i have view uitapgesturerecognizer(numberoftapsrequired = 1)
,and view has buttons.
i want change background-color of button tapped, select 1 change.
i don’t know how button change background-color. figureexample
- get rid of gesture
- create iboutletcollection called buttons buttons in it
add following code vc.
- (ibaction) didtapbutton:(uibutton*) sender { sender.backgroundcolor = [uicolor redcolor]; // or whatever // create iboutletcollection called buttons buttons in (uibutton *b in self.buttons) { if (b != sender) { b.backgroundcolor = [uicolor bluecolor]; // or whatever } } }
set action "touch inside" each button.
Comments
Post a Comment