Catransition Transition Animations Overview
Brief introduction
- Catransition, also known as transition animation, is a subclass of caanimation that can be used directly
- Transition animations are primarily used to animate the layer by providing a move-in/move-out screen
- Common applications for transition animations are Uinavigationcontroller
Precautions
- The default transition mode for transition animations is fade-out mode (Kcatransitionfade)
You can assign a value to the Type property of a transition animation using either a constant form or a string, such as
- Kcatransitionpush, constant form
- @ "Push", string form
There are only four constants for transition animation transitions in official documents.
The end value of the animation must be greater than or equal to the start value, otherwise no animation effect
Properties commonly used for transition animations
- Type (NSString *), the way the animation transitions
- Subtype (NSString *), the transition direction of the animation
- Startprogress (float), beginning of animation, with a value range of 0~1, representing the proportions in the entire animation
- Endprogress (float) animation end point, with a value range of 0~1, representing the proportions in the entire animation
Transitions for transition animations
Fade
- Cross-fade transitions
- Transition direction not supported
- The corresponding constant is Kcatransitionfade
Push
- New view launches the old view
- The corresponding constant is Kcatransitionpush
Movein
- The new view moves above the old view
- The corresponding constant is Kcatransitionmovein
Reveal
- Move old view off show new view below
- The corresponding constant is kcatransitionreveal
Cube
Oglflip
- Upside-down reversal effect
Suckeffect
- Shrinkage effect, as a piece of cloth is pumped away
- Transition direction not supported
Rippleeffect
- Drip effect
- Transition direction not supported
Pagecurl
Pageuncurl
Camerairishollowopen
- Camera lens Open Effect
- Transition direction not supported
Camerairishollowclose
- Camera lens off effect
- Transition direction not supported
Transition direction of Transitions animation
- Kcatransitionfromright, right
- Kcatransitionfromleft, left
- Kcatransitionfromtop, ON
- Kcatransitionfrombottom, down
Example
Implementation steps
- Create a Uiimageview control from storyboard and have it
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
- Change the Image property of ImageView
When you tap the screen, change the picture-(void) Touchesbegan: (nsset *) touches withevent: (uievent *) event{//Control picture loop show static Nsinteger i = p; if (i = = 4) {i = 1;} //Change picture nsstring *imagename = [nsstring stringWithFormat:@ "%zd", I]; Self. ImageView. image = [UIImage imagenamed:imagename];i++; Add animation [selfsetuptransition];}
- Implementing transition Animation Code
- (void)setupTransition{CATransition *animation = [CATransition animation];//设置动画的过渡方式animation.type = @"oglFlip";//设置动画的过渡方向animation.subtype = kCATransitionFromRight;//设置动画时长animation.duration = 0.5;//将动画添加到图层上[self.imageView.layer addAnimation:animation forKey:nil];}
Catransition transition Animations