UIView 的transitionFromView方法实现视图切换
#import "ViewController.h" @interface ViewController () @property (strong, nonatomic) IBOutlet UIImageView *imageViewFirst; @property (strong, nonatomic) IBOutlet UIImageView *imageViewSecond; @property(nonatomic,assign)__block BOOL rectToVisible; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; _rectToVisible=YES; [self.view addSubview:_imageViewFirst]; } -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { if (_rectToVisible) { [UIView transitionFromView:self.imageViewFirst toView:self.imageViewSecond duration:1 options:UIViewAnimationOptionTransitionFlipFromLeft completion:^(BOOL finished) { NSLog(@"animatioin complete"); _rectToVisible=!_rectToVisible; }]; } else { [UIView transitionFromView:self.imageViewSecond toView:self.imageViewFirst duration:1 options:UIViewAnimationOptionTransitionFlipFromRight completion:^(BOOL finished) { NSLog(@"animatioin complete"); _rectToVisible=!_rectToVisible; }]; } } @end