I have a CAGradientLayer overlaid on a CALayer. I want to animate it's opacity as I pan around the view they reside in.
So I simply have a CAGradientLayer instantiated like so:
this is how I instantiate the layer:
CAGradientLayer * gLayer = [CAGradientLayer layer];
NSArray * stops;
NSNumber *stopOne = [NSNumber numberWithFloat:0.0];
NSNumber *stopTwo = [NSNumber numberWithFloat:1.0];
[gLayer setColors:@[(id)clearColor.CGColor,(id)darkColor.CGColor]];
[gLayer setLocations:stops];
Then I change the opacity during the gesture: gLayer.opacity = (here I put the variable that changes between 0 - 1 as the pan changes)
So, even though this works, the change is not smooth because I am not animating it I guess.
How can I animate the opacity to be a fluid change? I guess the catch is that the animation has to be fast so that it follows the pan gesture change without lagging.
Any suggestion?
Thank you