动画旋转UIImageView在swift中 [英] animate rotation UIImageView in swift
本文介绍了动画旋转UIImageView在swift中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正试图在Swift中为 UIImageView
的180度旋转设置动画
I'm trying to animate a rotation of 180 degrees of a UIImageView
in Swift
UIView.animateWithDuration(1.0, animations: { () -> Void in
self.arrowImageView.transform = CGAffineTransformMakeRotation(CGFloat(180 * M_PI))
}) { (succeed) -> Void in
}
但根本不是动画。
我想使用animateWithDuration,因为我想在某些时候使用 CGAffineTransformMakeIdentity
使用它 UIView
动画有效。
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()
推荐答案
这是用于旋转imageview的代码。 swift 3.0
Here is code to rotate imageview. swift 3.0
UIView.animate(withDuration:2.0, animations: {
self.dropDownImage.transform = CGAffineTransform(rotationAngle: CGFloat(imageRotation))
})
这篇关于动画旋转UIImageView在swift中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文