165 animating transitions in the screen

Source: Internet
Author: User

The effect is as follows:

ViewController.h

1 #import <UIKit/UIKit.h>23@interface  viewcontroller: Uiviewcontroller4@end

Viewcontroller.m

1 #import "ViewController.h"2 3 @interfaceViewcontroller ()4- (void) Layoutui;5-(Uiimageview *) NextView;6- (void) Animationdidstop: (NSString *) Animationid finished: (NSNumber *) finished context: (void*) context;7 @end8 9 @implementationViewcontrollerTen #defineKviewtag 1 One  A- (void) Viewdidload { - [Super Viewdidload]; -      the [self layoutui]; - } -  -- (void) didreceivememorywarning { + [Super didreceivememorywarning]; -     //Dispose of any resources the can be recreated. + } A  at- (void) Layoutui { -Self.view.backgroundColor =[Uicolor Blackcolor]; -      - [Self.view addsubview:[self NextView]; - } -  in- (void) touchesended: (Nsset *) touches withevent: (Uievent *)Event { -     StaticUiviewanimationtransition transition =Uiviewanimationtransitionnone; toUiimageview *imgvcurrent =[self nextview]; +      - [UIView Beginanimations:nil context:null]; the[UIView setanimationduration:2.0]; * [UIView setanimationdelegate:self]; $ [UIView setanimationdidstopselector: @selector (animationDidStop:finished:context:)];Panax Notoginseng [UIView setanimationtransition:transition forView:self.view Cache:yes]; - [[Self.view Viewwithtag:kviewtag] removefromsuperview]; the [Self.view addsubview:imgvcurrent]; + [UIView commitanimations]; A      the     //set the animation to an invalid state + [UIView Setanimationsenabled:no]; -     //Toggle Transition Effect $     Switch(transition) { $          CaseUiviewanimationtransitionnone://no transition effect; as the default value -          CaseUiviewanimationtransitionflipfromleft://Flip effect from left -          CaseUiviewanimationtransitionflipfromright://Flip effect from right the          CaseUiviewanimationtransitioncurlup: {//page up effect from bottom to top -transition++;Wuyi              Break; the         } -          CaseUiviewanimationtransitioncurldown: {//page down effect from top WuTransition =Uiviewanimationtransitionnone; -              Break; About         } $     } - } -  --(Uiimageview *) NextView { A     StaticBOOL Isfirstview =YES; +UIImage *img = [UIImage imagenamed: (Isfirstview?@"Animation1":@"Animation2")]; theIsfirstview =!Isfirstview; -      $Uiimageview *IMGV =[[Uiimageview alloc] initwithimage:img]; theImgv.tag =Kviewtag; theCGFloat widthofimg = Img.size.width *3;//zoom in at 3 times times the width of the original image as the picture width of the picture view theCGFloat heightofimg = Img.size.height *3;//zoom in at 3 times times the height of the original image, as the picture height of the picture view theImgv.frame = CGRectMake (Cgrectgetmidx (self.view.frame)-widthofimg/2, -Cgrectgetmidy (self.view.frame)-heightofimg/2+Ten, in widthofimg, the heightofimg); the     returnIMGV; About } the  the- (void) Animationdidstop: (NSString *) Animationid finished: (NSNumber *) finished context: (void*) Context { the     //set the animation to a valid state + [UIView Setanimationsenabled:yes]; - } the Bayi @end

165 animating transitions in the screen

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.