I want to add a text layer to a video for the last 4 seconds of the video. This is what i have so far:
// 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"];
The animation is added to the final video but the watermark is visible from the beginning of the video. How can I set the opacity to 0 before the animation starts?
(I have tried setting the opacity of the watermarkText to 0 but that seems to override the animation. )