1 //2 //VIEWCONTROLLER.M3 //07-Transitions Animation4 //5 //Created by Mac on 16/4/19.6 //copyright©2016 Year Mac. All rights reserved.7 //8 9 #import "ViewController.h"Ten One @interfaceViewcontroller () A -@property (Strong, nonatomic) Uiimageview *ImageView; - the - @property (Assign, nonatomic) Nsinteger index; - - + @end - + @implementationViewcontroller A at- (void) Viewdidload { - [Super Viewdidload]; - -Self.index =1; - - //1. Create ImageView inSelf.imageview = [[Uiimageview alloc] Initwithframe:cgrectmake (0,0, Self.view.frame.size.width, Self.view.frame.size.height- -)]; -Self.imageView.image = [UIImage imagenamed:@"1.jpg"]; toSelf.imageView.backgroundColor =[Uicolor Whitecolor]; +self.imageView.userInteractionEnabled =YES; - the [Self.view AddSubview:self.imageView]; * $ //2. Add gesturesPanax Notoginseng [self addregesture]; - } the +- (void) Addregesture { A the //1. Left hand gesture +Uiswipegesturerecognizer *swipe =[[Uiswipegesturerecognizer alloc] initwithtarget:self action: @selector (swipeleft:)]; -Swipe.direction =Uiswipegesturerecognizerdirectionleft; $ $ [Self.imageview addgesturerecognizer:swipe]; - - //2. Right hand gesture theUiswipegesturerecognizer *swiperight =[[Uiswipegesturerecognizer alloc] initwithtarget:self action: @selector (swiperight:)]; -Swiperight.direction =Uiswipegesturerecognizerdirectionright;Wuyi the [Self.imageview addgesturerecognizer:swiperight]; - } Wu - /** About * Rightswipegesture $ */ -- (void) Swiperight: (Uigesturerecognizer *) Swipe { - -Self.index--; A if(Self.index = =0) { +Self.index =9; the } -NSString *filename = [NSString stringWithFormat:@"%li.jpg", Self.index]; $Self.imageView.image =[UIImage imagenamed:filename]; the the //Transition Animation Back theCatransition *right =[catransition animation]; the //Right.type = @ "Pageuncurl"; -Right.type =@"Cube"; inRight.subtype = Kcatransitionfromleft;//the direction of the transition theRight.duration =1.0; the [Self.imageView.layer addanimation:right forkey:nil]; About } the the /** the * Leftswipegesture + */ -- (void) Swipeleft: (Uigesturerecognizer *) Swipe { the BayiSelf.index + +; the if(Self.index = =Ten) { theSelf.index =1; - } - theNSString *filename = [NSString stringWithFormat:@"%li.jpg", Self.index]; theSelf.imageView.image =[UIImage imagenamed:filename]; the the //Add Transitions: Draw page-flipping effects -Catransition *left =[catransition animation]; the //Left.type = @ "Pagecurl"; theLeft.type =@"Cube"; theLeft.subtype = Kcatransitionfromright;//Excessive Direction94Left.duration =1.0; the [Self.imageView.layer addanimation:left forkey:nil]; the theNSLog (@"%li", Self.index);98 } About - @end
Transition Animation -01-day4