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)

StackOverflow https://stackoverflow.com/questions/13387291

Вопрос

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?

Это было полезно?

Решение

It's not so easy to do what you want, you have to start to see this touches tutorial from Apple Developer program

Другие советы

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

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top