开发者

CATransaction duration not working

I set a few CALayer transform and bounds modifications, within a CATransaction. However, regardless the method I use (key-value, setAnimationDuration) there is no animation, the changes are done, but immediately without transition. Do you have any idea why? Thanks!

   /* 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 convertPoi开发者_JAVA百科nt:thecentre toView:AnotherUIImageView]];
        AnUIImageView.layer.hidden=YES;

*/ // the code above works, i show it to be complete

        [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];


CALayers that are associated with a UIView (as in, they're accessed via view.layer) do not participate in implicit animations, regardless of how you configure your CATransaction. You either need to use explicit animations (using the appropriate subclass of CAAnimation) or you need to use UIView animations.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜