It's not so easy to do what you want, you have to start to see this touches tutorial from Apple Developer program
How to make two specific images, when a user places one on top of the other, create a third specified image (all of them pre-created images)
-
29-11-2021 - |
Frage
I would like the user to be able to press and drag one image (ex: image1.png) and place it over another (ex: image2.png). When the user releases, a third image (ex: image3.png) is added to the screen. How could I go about doing that in xcode?
Lösung
Andere Tipps
here is a code sample for the image moving:
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:self.view];
if (CGRectContainsPoint([image1 frame], location)) {
images.center = location;
if (CGRectContainsPoint([image1 frame], [image2 frame]) {
//place your code when image1 = images2
[self.view addSubview:image3];
}
}
}
i think something like this could work
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow