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

 

posted @ 2015-03-31 10:33  曹县三胖暴打大猩猩  阅读(1071)  评论(0编辑  收藏  举报