iOS Tap gesture state begin doesn't hit

前端 未结 5 1089
半阙折子戏
半阙折子戏 2021-01-12 13:56

I have made a view clickable with a tap gesture recognizer, which is working just fine. But I want to highlight the view when the touch happens en remove it when the touch e

5条回答
  •  萌比男神i
    2021-01-12 14:45

    You can also use touchesBegan:withEvent: and touchesEnded:withEvent: methods.

    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
        NSSet *t = [event touchesForView:_myView];
        if([t count] > 0) {
            // Do something 
        }
    }
    
    - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
        NSSet *t = [event touchesForView:_myView];
        if([t count] > 0) {
            // Do something
        }
    }
    

提交回复
热议问题