如何撤消此动画?斯威夫特3

时间:2017-08-03 14:59:48

标签: swift animation

这是我目前正在使用的动画,我想知道如何反转代码以使动画从右到左?

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")

1 个答案:

答案 0 :(得分:0)

尝试:

 leftToRightTransition.subtype = kCATransitionFromLeft