hello, i'm about to developp a memory game for children, and i want to know how to flip between two UIImage with animation? any help..
A:
You should have a view (UIView
) that will contain the displayed image view and swap between them on touch (either implement a touch events or use a button above the image views or use buttons instead of image views).
Next is a sample code for swapping 2 image views inside one container view (as described above):
// setup the animation group
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.75];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(transitionDidStop:finished:context:)];
// swap the views and transition
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:containerView cache:YES];
[imageView1 removeFromSuperview];
[containerView addSubview:imageView2];
[UIView commitAnimations];
You can also see the Elements sample project by Apple with a working example...
Michael Kessler
2010-08-02 08:08:39