Another problem with animation on a layer to make it scale and show like growing from bottom left, somewhat similar to the figure :
---------------
| |
|---------- |
| | |
| | |
|----- | |
| | | |
---------------
I have tried some animations but not able to achieve it exactly the way i want. Please suggest. Currently using following code to scale:
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];
You should set a different anchorPoint to acheive that effect.
layer.anchorPoint = CGPointMake(0.0f, 1.0f);
I hope this can help 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)
}
All of this doesn't work for me. Methods that 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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With