CoreAnimation - Opacity Fade In and Out Animation Not Working

后端 未结 11 1924
悲&欢浪女
悲&欢浪女 2020-12-08 05:02

I\'m attempting to create a fairly simple CoreAnimation for use in an AVComposition. My goal is to create a CALayer which, through various sublayer

11条回答
  •  旧时难觅i
    2020-12-08 05:54

    LenK's answer worked perfectly for me. If anyone is interested, I re-wrote for Obj-C (note I also slightly changed the key frames on fade in):

    CAKeyframeAnimation *fadeInAndOutAnimation = [CAKeyframeAnimation animationWithKeyPath:@"opacity"];
    fadeInAndOutAnimation.beginTime = CACurrentMediaTime() + beginTime;
    fadeInAndOutAnimation.duration = duration;
    fadeInAndOutAnimation.keyTimes = @[@0.0, @( 2.0 / 8.0 ), @( 5.0 / 8.0 ), @1.0];
    fadeInAndOutAnimation.values = @[@0.0, @1.0, @1.0, @0.0];
    fadeInAndOutAnimation.removedOnCompletion = false;
    fadeInAndOutAnimation.fillMode = kCAFillModeForwards;
    

提交回复
热议问题