Objective c 如何在动画中使用过渡

Objective c 如何在动画中使用过渡,objective-c,caanimation,Objective C,Caanimation,我想使用CAKeyframeAnimation显示一些图像,如何在图像之间执行转换?或者如何将cattransition添加到动画?例如:图像1渐出后图像2渐入,图像2渐出后图像3渐入,等等 - (void)animateImages { CAKeyframeAnimation *keyframeAnimation = [CAKeyframeAnimation animationWithKeyPath:@"contents"]; keyframeAnimation.values

我想使用
CAKeyframeAnimation
显示一些图像,如何在图像之间执行
转换?或者如何将
cattransition
添加到
动画
?例如:图像1渐出后图像2渐入,图像2渐出后图像3渐入,等等

- (void)animateImages
{
    CAKeyframeAnimation *keyframeAnimation = [CAKeyframeAnimation animationWithKeyPath:@"contents"];
    keyframeAnimation.values = self.imagesArray;

    keyframeAnimation.repeatCount = 1.0f;
    keyframeAnimation.duration = kAnimationDuration; // static const with your value

    keyframeAnimation.delegate = self;

    keyframeAnimation.removedOnCompletion = NO;
    keyframeAnimation.fillMode = kCAFillModeForwards;

    CALayer *layer = self.animationImageView.layer;

    [layer addAnimation:keyframeAnimation
                 forKey:@"girlAnimation"];
}

一张图片一层效果很好。我可以在每一层的开始/结束处添加动画,以显示输入/输出转换。

可能这个链接对您有帮助,我想在图像之间进行转换,例如:image1淡出然后image2淡入,image2淡出然后image3淡入,等等