How can I animate the height of a CALayer with a source coming from below rather than from above?

I want to animate a simple CALayer to move up and down in response to incoming data (bands on the graphic equalizer)

CALayer should remain fixed along the bottom and move up and down as the height revives.

Can anyone advise a better way to achieve this without having to animate the origin coordinate and height?

+4
source share
1 answer

, , anchorPoint . , X Y 0 1 , .

yourLayer.anchorPoint = CGPointMake(0.5, 1.0);

( , "bounds.size.height", ):

// set the new bounds of yourLayer here...

CABasicAnimation *grow = [CABasicAnimation animationWithKeyPath:@"bounds.size.height"];
grow.fromValue = @0;   // from no height
grow.toValue   = @200; // to a height of 200
grow.duration  = 0.5;
// add any additional animation configuration here...
[yourLayer addAnimation:grow forKey:@"grow the height of the layer"];

  • , .
  • Core Animation .
+9

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


All Articles