ios - animate rotation UIImageView in swift -


i'm trying animate rotation of 180 degrees of uiimageview in swift

    uiview.animatewithduration(1.0, animations: { () -> void in         self.arrowimageview.transform = cgaffinetransformmakerotation(cgfloat(180 * m_pi))     }) { (succeed) -> void in      } 

but isnt animating @ all. want use animatewithduration cause want make @ point using cgaffinetransformmakeidentity

using uiview animations works.

    uiview.beginanimations(nil, context: nil)     uiview.setanimationduration(1)     uiview.setanimationcurve(uiviewanimationcurve.easein)     let radians = cgfloat(180 * m_pi / 180)     arrowimageview.transform = cgaffinetransformmakerotation(radians)     uiview.commitanimations() 

first of all, if want rotate 180 degrees, has translate radians. 180 degrees in radians pi. 360 degrees 2 * pi. 180 * pi make animation spin around 90 times in 1 second , end original orientation.

secondly, i'm not sure why code isn't working, know code below work:

let rotationanimation = cabasicanimation(keypath: "transform.rotation") rotationanimation.fromvalue = 0.0 rotationanimation.tovalue = m_pi rotationanimation.duration = 1.0  self.arrowimageview.layer.addanimation(rotationanimation, forkey: nil) 

Comments