UIView转场动画

//  CZViewController.m

//  08-转场动画

//

//  Created by apple on 16/07/14.

//  Copyright (c) 2014年itcast. All rights reserved.

#import"CZViewController.h"

@interfaceCZViewController()

@property(weak,nonatomic)IBOutletUIImageView*imageView;

@property(nonatomic,assign)intindex;

@end

@implementationCZViewController

- (IBAction)swipe:(UISwipeGestureRecognizer*)sender

{

//判断方向

intoption;

if(sender.direction==UISwipeGestureRecognizerDirectionLeft) {

NSLog(@"left");

//        anim.subtype = kCATransitionFromRight;

option =UIViewAnimationOptionTransitionCurlDown;

self.index++;

}else{

NSLog(@"right");

//        anim.subtype = kCATransitionFromLeft;

option =UIViewAnimationOptionTransitionCurlUp;

self.index--;

}

//更新imageView中的图像

if(self.index<=0) {

self.index=5;

}elseif(self.index==6) {

self.index=1;

}

NSString*imageName = [NSStringstringWithFormat:@"%d.jpg",self.index];

self.imageView.image= [UIImageimageNamed:imageName];

//添加块代码转场

[UIViewtransitionWithView:self.viewduration:1.0foptions:optionanimations:^{

}completion:nil];

}

@end

你可能感兴趣的:(UIView转场动画)