Override method of controller
override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {
}
than check if any touch is inside of your views rect using function CGRectContainsPoint
You can add a button on the top of yourView and add touchDrag Inside control to it.
let button = UIButton(frame: yourView.bounds)
button.addTarget(target: self, action:#selector(self.yourmethodName), forControlEvents: .TouchDragInside)
Apple Documentation Reference :
TouchDragInside An event where a finger is dragged inside the bounds of the control.
Available in iOS 2.0 and later.
TouchDragOutside An event where a finger is dragged just outside the bounds of the control.
Available in iOS 2.0 and later.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.