Can I animate the radial gradient in the iPhone?

I would like to animate the radial gradient in order to compress and increase the inner radius, as if it were pulsating.

Now I am showing the gradient using CGGradient, but I'm not sure how to animate it. I saw this topic

Can you change the gradients using Quartz in iPhone?

This explains how to animate a linear gradient using CAGradientLayer, but it doesn't seem to lead to a radial gradient.

Is there an easy way to animate a CGGradient or somehow create a radial gradient of a CAGradientLayer?

Any thoughts are appreciated.

+3
source share
1 answer

Core Image, . - , .; -)

CAGradientLayer , .

, , Core Animation, - , .

. , , , , , . , :

CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"transform"];
[anim setFromValue:[NSValue valueWithCATransform3D:CATransform3DIdentity]];
// Scale x and y up
[anim setToValue:[NSValue valueWithCATransform3D:
                CATransform3DMakeScale (1.0f, 1.0f,0.0f)]];
[anim setAutoreverses:YES];
[anim setRepeatCount:HUGE_VALF];

[[gradientView layer] addAnimation:anim];

, , , ( ).

, , , , , , . , . . , , , .

, - . Core Animation /. , , (, innerRadius), -drawLayerInContext. , , . , , , .

.

+2

Source: https://habr.com/ru/post/1749648/


All Articles