ios核心動畫之專場動畫

來源:互聯網
上載者:User

標籤:

 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 @end10 11 @implementation NJViewController12 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核心動畫之專場動畫

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.