【发布时间】:2016-06-28 06:17:36
【问题描述】:
我是 swift 和 iPhone 开发的新手。最近我正在研究一个我必须垂直旋转图像的主题。
我几乎解决了这个问题,但问题是我的图像在旋转,但在旋转时它显示了 50% 的图像。这是视频中问题的链接。 http://screencast.com/t/VI4yZ0a8Wr
这里也是我正在使用的代码
func animationRotationEffect(view:UIView,animationTime:Float)
{
UIView.animateWithDuration(NSTimeInterval(animationTime), animations: { () -> Void in
/* previously used
same result produced as below
var animation:CABasicAnimation = CABasicAnimation(keyPath: "transform")
animation.toValue = NSValue(CATransform3D:CATransform3DMakeRotation(CGFloat(M_PI), 1, 0, 0))
animation.duration = CFTimeInterval(animationTime)
animation.cumulative = false
animation.repeatCount = 1
view.layer.addAnimation(animation, forKey: nil)
*/
let animate = CABasicAnimation(keyPath: "transform.rotation.x")
animate.duration = CFTimeInterval(animationTime)
animate.repeatCount = Float.infinity
animate.fromValue = 0.0
animate.toValue = Float(M_PI * 2.0)
view.layer.addAnimation(animate, forKey: nil)
})
}
如果有人可以帮助我,那将非常有帮助。
提前致谢,
尼克松
【问题讨论】: