Encapsulation of Iphone page Jump Animation

Source: Internet
Author: User

In the project, I want the page Jump to have different animation effects. I am a person who likes to submit public code and write it as a Tool class. Of course, this will not happen. Well, check the Code:
. H file:
[Cpp]
# Import <Foundation/Foundation. h>
# Import <QuartzCore/QuartzCore. h>
 
@ Interface MyAnimationUtil: NSObject {

}
 
 
+ (CATransition *) getAnimation :( NSInteger) mytag;
 
 
@ End

. M file
[Cpp]
# Import "MyAnimationUtil. h"
# Include <stdlib. h>
 
@ Implementation MyAnimationUtil
 
 
// Obtain the animation
+ (CATransition *) getAnimation :( NSInteger) mytag {

CATransition * animation = [CATransition animation];
Animation. delegate = self;
Animation. duration = 0.7;
Animation. timingFunction = UIViewAnimationCurveEaseInOut;

Switch (mytag ){
Case 1:
Animation. type = kCATransitionFade;
Break;
Case 2:
Animation. type = kCATransitionPush;
Break;
Case 3:
Animation. type = kCATransitionReveal;
Break;
Case 4:
Animation. type = kCATransitionMoveIn;
Break;
Case 5:
Animation. type = @ "cube ";
Break;
Case 6:
Animation. type = @ "suckEffect ";
Break;
Case 7:
Animation. type = @ "oglFlip ";
Break;
Case 8:
Animation. type = @ "rippleEffect ";
Break;
Case 9:
Animation. type = @ "pageCurl ";
Break;
Case 10:
Animation. type = @ "pageUnCurl ";
Break;
Case 11:
Animation. type = @ "cameraIrisHollowOpen ";
Break;
Case 12:
Animation. type = @ "cameraIrisHollowClose ";
Break;
Default:
Break;
}


Int I = (int) rand () % 4;
Switch (I ){

Case 0:
Animation. subtype = kCATransitionFromLeft;
Break;
Case 1:
Animation. subtype = kCATransitionFromBottom;
Break;
Case 2:
Animation. subtype = kCATransitionFromRight;
Break;
Case 3:
Animation. subtype = kCATransitionFromTop;
Break;
Default:
Break;
}
Return animation;
}
 
 
 
@ End

The call is as follows:
[Cpp]
UserRegisterViewController * userregister = [[UserRegisterViewController alloc] initWithNibName: @ "UserRegisterViewController" bundle: nil];
Userregister. userregisterdelegate = self. rootdelegate;
[Self. navigationController pushViewController: userregister animated: NO];
CATransition * animation = [MyAnimationUtil getAnimation: 6];
[Self. navigationController. view. layer addAnimation: animation forKey: nil];
[Userregister release];


From RiverAM's column

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.