Сначала включите мультитач на вашем UIView
:
self.multipleTouchEnabled = true
Затем сохраните словарь для UITouch
объектов. Одинаковые UITouch
объекты передаются в touchesBegan
, touchesMoved
и touchesEnded
:
var touchTypes = Dictionary<UITouch, Int>()
override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
for touchObject in touches {
touchTypes.updateValue(i, forKey: touch as UITouch) //determine i for your own implementation
}
}
override func touchesMoved(touches: NSSet, withEvent event: UIEvent) {
let type = touchTypes[touch] //depending on this value, do something
}
override func touchesEnded(touches: NSSet, withEvent event: UIEvent) {
for touchObject in touches {
touchTypes.removeValueForKey(touchObject as UITouch)
}
}