我想在视频的最后4秒添加一个文本层。这是我目前的情况:
// 1 - Set up the watermark text layer
CATextLayer *waterMarkText = [[CATextLayer alloc] init];
[waterMarkText setFont:@"Helvetica-Neue"];
[waterMarkText setFontSize:30];
[waterMarkText setFrame:CGRectMake(0, 0, self.size.width, 80)];
[waterMarkText setString:@"made with Videofy"];
[waterMarkText setAlignmentMode:kCAAlignmentRight];
[waterMarkText setForegroundColor:[[UIColor whiteColor] CGColor]];
//Fade In the watermark
CABasicAnimation *fadeInAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
fadeInAnimation.duration = 2;
fadeInAnimation.fromValue = [NSNumber numberWithFloat:0.0];
fadeInAnimation.toValue = [NSNumber numberWithFloat:1.0];
fadeInAnimation.beginTime = videoDuration - 4;
fadeInAnimation.removedOnCompletion = NO;
[overlayLayer addAnimation:fadeInAnimation forKey:@"animateOpacity"];
在最终视频中加入了动画,但水印从视频一开始就可见。 如何在动画开始前将不透明度设置为0?
(我已尝试将watermarkText的不透明度设置为0,但似乎会覆盖动画。)