检查是否同时触摸了不同的视图

时间:2016-07-05 09:23:38

标签: swift uiview touch uitouch

我的ViewController上有很少的UIView 我怎样才能检查他们现在是否全部接触过?它们被放置在屏幕的不同侧面,每个都必须用分开的手指触摸

1 个答案:

答案 0 :(得分:1)

使用touchesEnded委托

override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
        startTouchPosition = touches.first?.locationInView(self)
        let touch = touches.first
        if let touchPoint = touch?.locationInView(self){
            for view in self.views{
                if(view.containsPoint(touchPoint)){

                }
            }
        }
    }