iOS Detect tap down and touch up of a UIView

前端 未结 5 2109
忘掉有多难
忘掉有多难 2020-12-01 05:06

I am stuck with a problem of determining how to detect a UIView being touched down and UIView being tapped. When it is touched down, I want the UIView to change its backgrou

5条回答
  •  孤独总比滥情好
    2020-12-01 05:40

    In every UIControl subclass (UIButton, etc) you can use this to subscribe to a specific set of UIControlEvent:

    addTarget:action:forControlEvents
    

    You should add target with appropriate selector for UIControlEventTouchDown and another target/selector for UIControlEventTouchUpInside event.

    UIControl reference

提交回复
热议问题