[英]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.