How can I flip an UIImageView?
create two UIImageView frontImageView & backImageView
create one UIView containerView to contain UIImageView
Show frontImageView in the beginning.
after flip, show backImageView
code:
// before flip
frontImageView = [[UIImageView alloc] initWithImage:[UIImage
imageNamed:@"test.png"]];
containerView = [[UIView alloc] initWithFrame:frontImageView.bounds];
containerView.center = CGPointMake(200,200);
[self.view addSubview:containerView];
[containerView addSubview:frontImageView];
-(IBAction)flipButtonClicked:(id)sender
{
backImageView = [[UIImageView alloc] initWithImage:[UIImage
imageNamed:@"cardback.png"]];
backImageView.center = frontImageView.center;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
forView:containerView
cache:YES];
[frontImageView removeFromSuperview];
[containerView addSubview:backImageView];
[UIView commitAnimations];
}