[英]move a CALayer (add animation)
好吧,我有一个CALayer layer
,我想用CADisplaylink移动它。 喜欢 :
layer.center=CGPointMake(layer.center.x + 10, layer.center.y + 10);
但是我不能使用图层的center
或position
。这是我的问题,我想让它像uiimageview一样移动。
要移动图层,请尝试使用此方法
-(void)moveLayer:(CALayer*)layer to:(CGPoint)point{
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"];
animation.fromValue = [layer valueForKey:@"position"];
animation.toValue = [NSValue valueWithCGPoint:point];
layer.position = point;
[layer addAnimation:animation forKey:@"position"];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.