#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (
void)viewDidLoad {
[
super viewDidLoad];
}
- (
void)didReceiveMemoryWarning {
[
super didReceiveMemoryWarning];
}
- (
IBAction)
UIButton:(
UIButton *)sender {
UIView* backView = [
self.view viewWithTag:
10];
UIView* view1 = [
self.view viewWithTag:
11];
UIView* view2 = [
self.view viewWithTag:
12];
NSArray* viewArr = [backView subviews];
NSInteger index1 = [viewArr indexOfObject:view1];
NSInteger index2 = [viewArr indexOfObject:view2];
[backView exchangeSubviewAtIndex:index1 withSubviewAtIndex:index2];
[
UIView beginAnimations:
nil context:
nil];
[
UIView setAnimationDuration:
1];
[
UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[
UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:backView cache:
YES];
switch (sender
.tag) {
case 1:
[
UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:backView cache:
YES];
break;
case 2:
[
UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:backView cache:
YES];
break;
case 3:
[
UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:backView cache:
YES];
break;
case 4:
[
UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:backView cache:
YES];
break;
default:
break;
}
[
UIView commitAnimations];
}
@end