ios - How can I animate the height of a CALayer with the origin coming from the bottom instead of the top? -
i want animate simple calayer move , down in response incoming data (bars on graphic equaliser)
the calayer should remain fixed along bottom , move , down height animated.
can advise on best way achieve without having animate origin y coord height?
if want layer grow , shrink bottom, should set own anchorpoint
on layer bottom. anchor point specified in layers unit coordinate space both x , y range 0 1 inside of bounds, no matter size.
yourlayer.anchorpoint = cgpointmake(0.5, 1.0);
then animation, animate bounds (or better, can animate "bounds.size.height"
, since height changing):
// set new bounds of yourlayer here... cabasicanimation *grow = [cabasicanimation animationwithkeypath:@"bounds.size.height"]; grow.fromvalue = @0; // no height grow.tovalue = @200; // height of 200 grow.duration = 0.5; // add additional animation configuration here... [yourlayer addanimation:grow forkey:@"grow height of layer"];
- you can read more anchor point in this article wrote couple of years ago.
- you can read more key-value coding extensions core animation in documentation.
Comments
Post a Comment