1 CATransition *animation = [CATransitionanimation];
2 animation.delegate = self;
3 animation.duration = 0.7;
4 animation.timingFunction = UIViewAnimationCurveEaseInOut;
5
6 switch (tag) {
7 case 101:
8 animation.type = kCATransitionFade; // 淡化
9 break;
10 case 102:
11 animation.type = kCATransitionPush; // 推挤
12 break;
13 case 103:
14 animation.type = kCATransitionReveal; // 揭开
15 break;
16 case 104:
17 animation.type = kCATransitionMoveIn; // 覆盖
18 break;
19 case 201:
20 animation.type = @"cube"; // 立方体
21 break;
22 case 202:
23 animation.type = @"suckEffect"; // 吸收
24 break;
25 case 203:
26 animation.type = @"oglFlip"; // 翻转
27 break;
28 case 204:
29 animation.type = @"rippleEffect"; // 波纹
30 break;
31 case 205:
32 animation.type = @"pageCurl"; // 翻页
33 break;
34 case 206:
35 animation.type = @"pageUnCurl"; // 反翻页
36 break;
37 case 207:
38 animation.type = @"cameraIrisHollowOpen"; // 镜头开
39 break;
40 case 208:
41 animation.type = @"cameraIrisHollowClose"; // 镜头关
42 break;
43 }
44
45 switch (self.typeID) {
46 case 0:
47 animation.subtype = kCATransitionFromLeft;
48 break;
49 case 1:
50 animation.subtype = kCATransitionFromBottom;
51 break;
52 case 2:
53 animation.subtype = kCATransitionFromRight;
54 break;
55 case 3:
56 animation.subtype = kCATransitionFromTop;
57 break;
58 default:
59 break;
60 }
61
62 [[self.viewlayer] addAnimation:animation forKey:@"animation"];
1 CGContextRef context = UIGraphicsGetCurrentContext(); // 得到上下文环境
2
3 [UIView beginAnimations:nil context:context];
4 [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; // 设置动画变化曲线
5 [UIView setAnimationDuration:kDuration];
6 switch (tag) {
7 case 105: // 下翻
8 [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown
9 forView:self.view cache:YES];
10 break;
11 case 106: // 上翻
12 [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp
13 forView:self.view cache:YES];
14 break;
15 case 107: // 左转
16 [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
17 forView:self.view cache:YES];
18 break;
19 case 108: // 右转
20 [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight
21 forView:self.view cache:YES];
22 break;
23 }
24 [UIView setAnimationDelegate:self];
25 // 动画完毕后调用某个方法
26 //[UIView setAnimationDidStopSelector:@selector(animationFinished:)];
27 [UIView commitAnimations];