这是我目前正在使用的动画,我想知道如何反转代码以使动画从右到左?
func leftToRightAnimation(duration: TimeInterval = 0.5, completionDelegate: AnyObject? = nil) {
// Create a CATransition object
let leftToRightTransition = CATransition()
// Set its callback delegate to the completionDelegate that was provided
if let delegate: CAAnimationDelegate = completionDelegate as! CAAnimationDelegate? {
leftToRightTransition.delegate = delegate
}
leftToRightTransition.type = kCATransitionPush
leftToRightTransition.subtype = kCATransitionFromRight
leftToRightTransition.duration = duration
leftToRightTransition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
leftToRightTransition.fillMode = kCAFillModeRemoved
// Add the animation to the View's layer
self.layer.add(leftToRightTransition, forKey: "leftToRightTransition")
答案 0 :(得分:0)
尝试:
leftToRightTransition.subtype = kCATransitionFromLeft