在自定义类中获取按钮触摸事件类型

时间:2018-07-04 02:52:35

标签: ios swift uibutton touch-event

是否可以在自定义类中获取按钮触摸事件类型(即touchupinside,touchupoutside,touchdragdown等)。

 class MyButton : UIButton {
    override func sendAction(_ action: Selector, to target: Any?, for event:        
    UIEvent?) {
         debugPrint("Am here")

         /* below code is just for understanding what i want
         if event.type == touchupinside {
              //do something
         }
         else if event.type == touchdragdown {
              //do something else
         }
         */

         super.sendAction(action, to: target, for: event)
}

}

0 个答案:

没有答案
相关问题