Transition Animation -01-day4

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.