вы можете создать свой путь
CGMutablePathRef thePath = CGPathCreateMutable();
, а затем в touchesBegan и touchesMoved добавить к вашему пути
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [touches anyObject];
if(touch){
CGPoint tapPoint = [touch locationInView: self.view];
CGPathMoveToPoint(thePath, NULL,tapPoint.x,tapPoint.y);
}
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [touches anyObject];
if(touch){
CGPoint tapPoint = [touch locationInView: self.view];
CGPathAddLineToPoint(thePath, NULL,tapPoint.x,tapPoint.y);
}
}
и на touchedEnded, как сказал Джошуа, создать CAKeyframeAnimation и установитьего путь к пути и установите другие свойства вашей анимации (продолжительность и т. д.) и примените его к вашему объекту