Video learning series 3: Adding a fade in effect to the watermark

To add a fade-in effect to the watermark, you can use a CABasicAnimation on the opacity property of the watermark layer.

Here’s how you can modify the addWatermark(to:watermark:) function to add a fade-in effect:

In this modified function, the opacity of the watermarkLayer is initially set to 0 (completely transparent). A CABasicAnimation is created to animate the opacity from 0 to 0.5 over a duration of 5.0 seconds. The animation begins at time zero (AVCoreAnimationBeginTimeAtZero), is not removed when completed, and continues to apply its effect after its active duration (fillMode = .forwards). The animation is added to the watermarkLayer with the key “opacity”.

This will create a fade-in effect for the watermark in the exported video. You can adjust the toValue and duration of the animation to control the final opacity and the speed of the fade-in effect.

In

,

Leave a Reply

Your email address will not be published. Required fields are marked *