1, Catransition Introduction:
2, simple use: 2-1, in the storyboard to build the interface:
2-2. Realize transition Animation:
1. #import "ViewController.h"
2.
[Email protected] Viewcontroller ()
[Email protected] (Weak, nonatomic) Iboutlet Uiimageview *imageview;
5.
6./** Image Index */
[Email protected] (Assign, Nonatomic) Nsinteger index;
[Email protected]
9.
[Email protected] Viewcontroller
11.
12.-(void) Viewdidload {
[Super Viewdidload];
Self.imageView.image = [UIImage imagenamed:@ "GIRL1"];
15.
16.}
17.
18.-(ibaction) Next {
self.index++;
if (Self.index = = 9) {
Self.index = 0;
22.}
NSString *imagename = [NSString stringwithformat:@ "Girl%zd", Self.index + 1];
Self.imageView.image = [UIImage imagenamed:imagename];
25.
26.//1. Creating animations
Catransition *anim = [catransition animation];
28.
29.//anim.type = Kcatransitionmovein;
Anim.type = @ "Cube";
31.
Anim.duration = 1.0;
33.
34.//2. Add animations
[Self.imageView.layer Addanimation:anim Forkey:nil];
36.}
37.
38.-(Ibaction) forward {
self.index--;
if (Self.index = =-1) {
Self.index = 8;
42.}
NSString *imagename = [NSString stringwithformat:@ "Girl%zd", Self.index + 1];
Self.imageView.image = [UIImage imagenamed:imagename];
45.
46.//1. Creating animations
Catransition *anim = [catransition animation];
48.
//Anim.type = Kcatransitionmovein;
Anim.type = @ "Cube";
Wuyi Anim.subtype = Kcatransitionfromleft;
Anim.duration = 1.0;
53.
54.//2. Add animations
[Self.imageView.layer Addanimation:anim Forkey:nil];
56.}
[Email protected]
Sample effect Diagram :
iOS Core notes--core animation-catransition