Core animation-transfer animation, core animation Transfer
Transfer Animation: CATransition
Attribute introduction:
① Type: animation effect of transition Animation
KCATransitionFade cross fade transition
The new kCATransitionMoveIn view is moved to the old view.
KCATransitionPush New View releases old view
KCATransitionReveal removes the old view and displays the new view below.
Private api for animation effects of transition Animation
PageCurl page up
PageUnCurl flip down one page
RippleEffect dripping Effect
SuckEffect: the effect of contraction is extracted from a cloth.
Cube Effect
OglFlip flip up and down
② Subtype: Transition animation effect direction
KCATransitionFromRight
KCATransitionFromLeft
KCATransitionFromTop
KCATransitionFromBottom
③ StartProgress start progress (0, 1)
④ EndProgress end progress
The above is an introduction to transition animation.
The Code is as follows:
First, create a UIImageView in Main. storyBoard, set the image and contentModel, right-click and drag it to the Project @ interface.
# Import "ViewController. h "@ interface ViewController () {// int index of the image;} @ property (weak, nonatomic) IBOutlet UIImageView * imageView; @ end @ implementation ViewController-(void) viewDidLoad {[super viewDidLoad];}-(IBAction) leftSwipe :( id) sender {[self changImageWithDirection: YES];}-(IBAction) rightSwipe :( id) sender {[self changImageWithDirection: NO];}-(void) changImageWithDirection :( BOOL) directi On {CATransition * animation = [CATransition animation]; animation. duration = 2; if (direction! = YES) {index --; NSLog (@ "to the right"); animation. type = @ "oglFlip"; // The up/down flip effect is animation. subtype = kCATransitionFromLeft; // orientation to left} else {index ++; NSLog (@ ""); animation. type = @ "cube"; // cube effect animation. subtype = kCATransitionFromRight;} if (index <0) {index = 6;} if (index> 6) {index = 0;} self. imageView. image = [UIImage imageNamed: [NSString stringWithFormat: @ "community administrator d.jpg", index + 1]; [self. imageView. layer addAnimation: animation forKey: @ ""] ;}@ end
The effect is as follows: