1

I have added PINCH,PAN,ROTATE Gesture for some objects. Due to the animator’s behaviours I could not Pinch,Pan and Rotate the objects. If I remove the animator behaviour’s such as gravity , boundaries, elasticity and snap then the gestures mentioned above are working fine.

Here is the code i have tried :

In Class I have declared :

var animator: UIDynamicAnimator!
var snap: UISnapBehavior!

In a function I have added collision to the objects like this,

       let tapPoint: CGPoint = recognizer.location(in: view)

         snap = UISnapBehavior(item: myArray, snapTo: tapPoint)


           let gravity = UIGravityBehavior(items: myArray )
         let direction = CGVector(dx: 0.0, dy: 0.0)
            gravity.gravityDirection = direction

           let boundries = UICollisionBehavior(items: myArray)
               boundries.addItem(item)
         boundries.translatesReferenceBoundsIntoBoundary = true

          let bounce = UIDynamicItemBehavior(items: myArray)
           bounce.elasticity = 0.5
           let push = UIPushBehavior(items: myArray, mode: .instantaneous)
            push.angle = -1.35
            push.magnitude = 0.0

            animator?.addBehavior(gravity)
            animator?.addBehavior(boundries)
            animator?.addBehavior(bounce)
            animator?.addBehavior(push)
           animator?.addBehavior(snap)

Here is the screen recorder link which, i have tried - https://drive.google.com/file/d/1Vsm8SjsNd0uenXHynNoFHatN3A1nWvNt/view?usp=sharing

Any help much appreciated pls...

PvDev
  • 791
  • 21
  • 67

0 Answers0