CoreAnimation - Opacity Fade In and Out Animation Not Working

后端 未结 11 1826
悲&欢浪女
悲&欢浪女 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条回答
  •  有刺的猬
    2020-12-08 05:58

    Man, so many complicated answers. The simplest way is just to add autoreverse. Voila.

    CABasicAnimation *fadeInAndOut = [CABasicAnimation animationWithKeyPath:@"opacity"];
    fadeInAndOut.duration = 5.0;
    fadeInAndOut.autoreverses = YES;
    fadeInAndOut.fromValue = [NSNumber numberWithFloat:0.0];
    fadeInAndOut.toValue = [NSNumber numberWithFloat:1.0];
    fadeInAndOut.repeatCount = HUGE_VALF;
    fadeInAndOut.fillMode = kCAFillModeBoth;
    [titleLayer addAnimation:fadeInAndOut forKey:@"myanimation"];
    

提交回复
热议问题