完成UIView.animateKeyframesWithDuration后,避免暂停

时间:2014-12-15 04:20:59

标签: objective-c xcode cocoa swift core-animation

如何使用非对称图像获得平滑的无限旋转动画?每次轮换之间我都会暂停一下。我尝试使用其他CalculationMode,但没有运气。有人有什么想法吗?

imageToRotate.hidden = false

let duration = 0.5
let delay = 0.0
let options = UIViewKeyframeAnimationOptions.CalculationModePaced | UIViewKeyframeAnimationOptions.Repeat

let fullRotation = CGFloat(M_PI * 2)

UIView.animateKeyframesWithDuration(duration, delay: delay, options: options, animations: {
    UIView.addKeyframeWithRelativeStartTime(0, relativeDuration: 0, animations: {
        self.imageToRotate.transform = CGAffineTransformMakeRotation(1/3 * fullRotation)
    })

    UIView.addKeyframeWithRelativeStartTime(0, relativeDuration: 0, animations: {
        self.imageToRotate.transform = CGAffineTransformMakeRotation(2/3 * fullRotation)
    })

    UIView.addKeyframeWithRelativeStartTime(0, relativeDuration: 0, animations: {
        self.imageToRotate.transform = CGAffineTransformMakeRotation(3/3 * fullRotation)
    })


    }, completion: {finished in


})

编辑:我尝试了"可能重复的#34;但不幸的是,@levigroke用非对称图像说我得到了一个" snap" 90度后回到原来的方向。他还说"其中一个不太优雅的解决方案,如下所示,将真正旋转图像,但是当动画重新启动时可能会出现明显的断言"。这是我最初的问题所以我觉得他的回答在我的案例中不会做。

0 个答案:

没有答案