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