0

I want to rotate a child view from its right corner from -90 to 0. I am not able to set its anchor point correctly and when I am changing anchor point complete view is getting changed its position. I need view to be rotate at it right corner at all the angle and animation should look like

Hinge animation

Basically i am looking for Hinge Animation. I seen some examples for Hinge animation but those are very complicated and not use full.

Please share if you have solution.

Thanks

Abhishek singh
  • 415
  • 7
  • 20

1 Answers1

0

You can use CABasicAnimation to achieve you effect in your view's layer :

view.layer.anchorPoint = CGPointMake(1.0, 0.0)
let animation = CABasicAnimation(keyPath: "transform.rotation.z")
animation.duration = 3.0
animation.fromValue = 0
animation.toValue = -90*M_PI / 180.0
view.layer.addAnimation(animation, forKey: "anim")
stefos
  • 1,235
  • 1
  • 10
  • 18
  • When i am using anchor point other then (0.5, 0.5) complete view position getting change from center to some different place. How can place view in center and hanging from its left corner.Animation is fine but only problem is view position as i mentioned in my question. It should look like holding a card from its left corner and hanging. – Abhishek singh Jun 14 '16 at 05:02