动画从顺时针方向反向逆时针方向

时间:2016-02-01 02:35:37

标签: ios xcode swift

我有一个基本上是圆形路径的动画。这是代码`

let curvedPath = CGPathCreateMutable()        
        var rectangle = CGRectMake(0,0,220,220)

        rectangle.origin.x = self.view.center.x - 110
        rectangle.origin.y = self.view.center.y - 110


        CGPathAddEllipseInRect(curvedPath, nil, rectangle)
        pathAnimation.path = curvedPath
        pathAnimation.duration = 5.0

        pathAnimation.repeatCount = Float.infinity

        pathAnimation.rotationMode = kCAAnimationRotateAuto
        obstacle.layer.addAnimation(pathAnimation, forKey: nil)`

我正在使用CGPaths!关于如何制作这个的任何想法?只需改变方向!

1 个答案:

答案 0 :(得分:1)

你没有告诉我们什么样的动画路径动画,或者是设置,所以很难知道如何反转动画。

这样做的一个简单方法是将图层翻转为镜像。您可以应用缩放变换并反转X或Y上的符号。然后您的旋转应该朝向另一个方向。

classdef MyClass

properties
    A
    B
end%public properties

methods

    function mc = MyClass(a,b)   % Constructor
        mc.A = a;
        mc.B = b;
    end

    function mc = set.A(mc, value) % setter for A
        mc = mc.commonSetter(value, 'A');
    end

    function mc = set.B(mc, value) %setter for B
        mc = mc.commonSetter(value, 'B');
    end


end%public methods

methods(protected = true)

    function mc = commonSetter(mc, property, value)
        if value <= 5;
            error([property ' should be less than 5');
        end
        mc.(property) = value;

    end%commonSetter()

end%protected methods


end%classdef