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

  1. get rid of gesture
  2. create iboutletcollection called buttons buttons in it
  3. 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