我是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)
})
}
如果有人能帮助我这将是非常有帮助的。
提前致谢,
尼克松
答案 0 :(得分:0)
也许这不是动画问题,请尝试将UIImageView
的方面和内容模式设置为此
imageView.contentMode = UIViewContentMode.ScaleAspectFit
有关UIViewContentMode枚举here
的更多信息