objective-c - 如何在CAKeyframeAnimation中使用过渡

标签 objective-c caanimation

我想使用CAKeyframeAnimation显示一些图像,如何在图像之间执行转换?或者如何将 CATransition 添加到 animation 中?如:image1淡出然后image2淡入,image2淡出然后image3淡入等

最佳答案

CAKeyframeAnimation:

- (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"];
}

关于objective-c - 如何在CAKeyframeAnimation中使用过渡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37958361/

相关文章:

iphone - 当应用 CAAnimation 时,AQGridView 单元格会被交换

swift - 使用未解析的标识符 'kCAFillModeForwards'

ios - 执行 Segue 后事情不起作用

ios - 用动画改变帧

ios - 无法进行正则表达式匹配

ios - 维护 View Controller 之间的信息

ios - 在两个贝塞尔路径形状之间制作动画

ios - 如果为其设置了 beginTime,CAEmitterLayer 不会添加基本动画

objective-c - 删除 wkwebview Objective C 中的缓存

iphone - 同一位置坐标中的多个注释( MKAnnotationView )