CATransaction持续时间不起作用

Nig*_*der 0 core-animation objective-c

我在CATransaction中设置了一些CALayer变换和边界修改.但是,无论我使用的方法(键值,setAnimationDuration)都没有动画,更改已完成,但立即没有过渡.你知道为什么吗?谢谢!

   /* CALayer*layer=[CALayer layer];
        layer.bounds =AnUIImageView.bounds;
        layer.contents=AnUIImageView.layer.contents;
        [AnotherUIImageView.layer addSublayer:layer];

        CGPoint thecentre=AnUIImageView.center;

        CALayer* layerInTarget=[AnotherUIImageView.layer.sublayers lastObject];
        [layerInTarget setPosition:[self.view convertPoint:thecentre toView:AnotherUIImageView]];
        AnUIImageView.layer.hidden=YES;
Run Code Online (Sandbox Code Playgroud)

*///上面的代码有效,我表明它是完整的

        [CATransaction begin];
        [CATransaction setValue:[NSNumber numberWithFloat:2.0f]
                         forKey:kCATransactionAnimationDuration];
       layerInTarget.position=[self.view convertPoint:AnotherUIImageView.center toView:AnotherUIImageView];
       layerInTarget.transform=CATransform3DMakeScale(0.6,0.6,0.6);
        [CATransaction commit];
Run Code Online (Sandbox Code Playgroud)

Lil*_*ard 7

CALayer与a相关联的UIView(如同在,通过它们访问view.layer)不参与隐式动画,无论您如何配置CATransaction.您需要使用显式动画(使用适当的子类CAAnimation)或者您需要使用UIView动画.