objective-c - 关于iOS中的动画效果
巴扎黑
巴扎黑 2017-04-17 17:27:12
0
1
283

原文地址:http://www.raywenderlich.com/76147/uikit-dynamics-tutorial-swift
在原文的最下面有这样一段代码,实现的大概效果是:当手指触摸屏幕某一点时,view就移动到那一点,我不是很清楚其中这段if语句,if语句的意思应该是把snap行为移除,可是这有什么作用,为什么把if语句删掉了就不能达到上面的效果

override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {

        if (snap != nil) {
            animator.removeBehavior(snap)
        }
        
        let touch = touches.first! as UITouch
        snap = UISnapBehavior(item: square, snapToPoint: touch.locationInView(view))
        animator.addBehavior(snap)
    }
巴扎黑
巴扎黑

reply all(1)
刘奇

That is used to block touch points that have not been completed or there is no reset after the event is completed, in response to your last click event.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template