首页 > 移动平台 > 详细

ios核心动画之专场动画

时间:2016-01-24 12:50:43      阅读:273      评论:0      收藏:0      [点我收藏+]
 1 #import "NJViewController.h"
 2 
 3 @interface NJViewController ()
 4 @property (weak, nonatomic) IBOutlet UIImageView *iconView;
 5 - (IBAction)nextBtnClick:(id)sender;
 6 - (IBAction)preBtnClick:(id)sender;
 7 
 8 @property (nonatomic, assign) int index;
 9 @end
10 
11 @implementation NJViewController
12 
13 // 下一张
14 - (IBAction)nextBtnClick:(id)sender {
15     self.index++;
16     if (self.index >7) {
17         self.index = 1;
18     }
19     
20     NSString *imageName = [NSString stringWithFormat:@"%d.jpg", self.index];
21     UIImage *newImage = [UIImage imageNamed:imageName];
22     self.iconView.image = newImage;
23     
24     // 1.创建核心动画
25     CATransition *ca = [CATransition animation];
26     // 1.1动画过渡类型
27     ca.type = @"cube";
28     // 1.2动画过渡方向
29     ca.subtype =  kCATransitionFromRight;
30     // 1.3动画起点(在整体动画的百分比)
31 //    ca.startProgress = 0.5;
32     ca.endProgress = 0.5;
33     
34     
35     // 动画时间
36     ca.duration = 1;
37     
38     // 2.添加核心动画
39     [self.iconView.layer addAnimation:ca forKey:nil];
40 }
41 
42 // 上一张
43 - (IBAction)preBtnClick:(id)sender {
44     self.index--;
45     if (self.index < 1) {
46         self.index = 7;
47     }
48     NSString *imageName = [NSString stringWithFormat:@"%d.jpg", self.index];
49     UIImage *newImage = [UIImage imageNamed:imageName];
50     self.iconView.image = newImage;
51     
52     // 1.创建核心动画
53     CATransition *ca = [CATransition animation];
54     // 1.1告诉系统执行什么动画
55     ca.type = @"cube";
56     ca.subtype =  kCATransitionFromLeft;
57     
58     ca.duration = 1;
59     
60     // 2.添加核心动画
61     [self.iconView.layer addAnimation:ca forKey:nil];
62 
63 }
64 @end

 

ios核心动画之专场动画

原文:http://www.cnblogs.com/PJHome/p/5154907.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!