CALayer scale animation for layer size starting from lower left and upper right

Another problem with the animation on the layer is that it scales and appears as growing on the bottom left, somewhat similar to a shape:

---------------    
|             |
|----------   |
|         |   |
|         |   |
|-----    |   |
|    |    |   |
---------------

I tried some animations, but could not achieve this exactly the way I want. Please suggest. Currently, the following code is used for scaling:

layer.anchorPoint = CGPointMake(1, 1);
CABasicAnimation *scale = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
[scale setFromValue:[NSNumber numberWithFloat:0.0f]];
[scale setToValue:[NSNumber numberWithFloat:1.0f]];
[scale setDuration:1.0f];
[scale setRemovedOnCompletion:NO];
[scale setFillMode:kCAFillModeForwards];
+5
source share
3 answers

You must install another anchorPoint to achieve this effect.

    layer.anchorPoint = CGPointMake(0.0f, 1.0f);
+6
source

All this does not work for me. Methods for fixing frames and points

- (CGRect) fixRect:(CGRect)rect inRect:(CGRect)container
{
    CGRect frame = rect;
    frame.origin.y = container.size.height - frame.origin.y - frame.size.height;
    return frame;
}
- (CGPoint) fixPoint:(CGPoint)point fromPoint:(CGSize)containerSize
{
    CGPoint frame = point;
    frame.y = size.height - frame.y;
    return frame;
}
+1
source

Hope this helps you:

let frame = pathView.frame
let anchorPoint = CGPointMake(0, 1) //Set the animation direction
let position = CGPointMake(frame.origin.x + anchorPoint.x * frame.size.width, frame.origin.y + anchorPoint.y * frame.size.height)
pathView.layer.anchorPoint = anchorPoint
pathView.layer.position = position
UIView.animateWithDuration(0.8){ () -> Void in
    pathView.layer.transform = CATransform3DMakeScale(0.5, 0.5, 1)
}
+1
source

All Articles