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