0
Im新增核心動畫。每次我調用動畫時,圖像都會從其位置移動到屏幕的左上角,然後移動,然後返回到原始位置。如何讓圖像移動50個單位,停止,然後重複,如果再次按下按鈕。 代碼:動畫調用後UIImage視圖重置
-(IBAction)preform:(id)sender{
CGPoint point = CGPointMake(50, 50);
CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"position"];
anim.fromValue = [NSValue valueWithCGPoint:point];
anim.toValue = [NSValue valueWithCGPoint:CGPointMake(point.x + 50, point.y)];
anim.duration = 1.5f;
anim.repeatCount =1;
anim.removedOnCompletion = YES;
anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
[imView.layer addAnimation:anim forKey:@"position"];
}