CALayer按照从左下到右上的尺寸缩放animation

animation的另一个问题在一个图层上,使其从左下angular逐渐变大并显示出来,有点类似于graphics:

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

我尝试了一些animation,但无法完全按照我想要的方式实现。 请build议。 目前使用以下代码来进行缩放:

 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]; 

你应该设置一个不同的anchorPoint来达到这个效果。

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

所有这一切都不适合我。 固定框架和点的方法

 - (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; } 

我希望这可以帮助你:

 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) }