Objective-C Question

How to make UIView clickable

I have a custom UIView that contains a UILabel and a UIImageView. How do I make my UIView clickable? I want the background of the UIView to change any time a user starts to press down on the UIView. The color should change back when the user lifts up on the button. I also need to be able to handle the click event.

Answer Source
-(void)addGestureRecogniser:(UIView *)touchView{

    UITapGestureRecognizer *singleTap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(changecolor)];
    [touchView addGestureRecognizer:singleTap];

  // do something


1`) this is code snippet where in u need to pass the view as a parameter so as to make it clickable.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download