How to drag a UIImageView along a Bezier path

I am developing a game in which a UIImageView moves along the Bezier path. I want to ensure user interaction with the moving UIImageView so that the user can direct the UIImageView by touching the UIImageView and dragging it along the way! How to do it?

enter image description here

+6
source share
3 answers

Just use the panorama gesture and add it to the UIImageView and specify your path along which the user moves it. Gesture for carrying

This link may be useful for understanding and implementation. Anything else will tell me.

0
source

You must check if the coordinates of the touch point are inside the Beizer path. If it is inside, enable UITouch and Movement, otherwise not. Give If Condition accordingly.

0
source

Please try this ...

Here selectedImageCat is the gobal uiimageview object, and touchimgView is the selection (touched) imageview

 -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { for (UITouch *touchPoint in touches) { if(CGRectContainsPoint(touchimgView.frame, [touchPoint locationInView:self.view])) selectedImageCat=(UIImageView*)touchimgView; } } -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { if (selectedImageCat!=nil) { CGPoint pt = [[touches anyObject] locationInView:self.view]; [selectedImageCat setCenter:pt]; } } -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { //here you provide final frame for touchimgView object } 
0
source

Source: https://habr.com/ru/post/971236/


All Articles