核心動畫——轉場動畫,核心動畫轉場

來源:互聯網
上載者:User

核心動畫——轉場動畫,核心動畫轉場

轉場動畫:CATransition

屬性介紹:

    ①type:轉場動畫的動畫效果

         kCATransitionFade   交叉淡化過渡

         kCATransitionMoveIn 新視圖移到舊視圖上面

         kCATransitionPush   新視圖把舊視圖推出去

         kCATransitionReveal 將舊視圖移開,顯示下面的新視圖

     轉場動畫的動畫效果 私人api

       pageCurl            向上翻一頁

       pageUnCurl          向下翻一頁

       rippleEffect        滴水效果

       suckEffect          收縮效果 如一塊布被抽走

       cube                立方體效果

       oglFlip             上下翻轉效果

  ②subtype:轉場動畫的效果方向

         kCATransitionFromRight

         kCATransitionFromLeft

         kCATransitionFromTop

         kCATransitionFromBottom

    ③startProgress 開始進度 (0,1)

    ④endProgress 結束進度

以上就是關於轉場動畫的介紹

具體代碼如下:

首先在Main.storyBoard裡面建立一個UIImageView,設定image、contentModel,點擊右鍵不放將他拖到工程@interface裡面。

#import "ViewController.h"@interface ViewController (){    //圖片的標記    int index;}@property (weak, nonatomic) IBOutlet UIImageView *imageView;@end@implementation ViewController- (void)viewDidLoad {    [super viewDidLoad];    }- (IBAction)leftSwipe:(id)sender {    [self changImageWithDirection:YES];        }- (IBAction)rightSwipe:(id)sender {    [self changImageWithDirection:NO];}- (void)changImageWithDirection:(BOOL)direction{       CATransition *animation = [CATransition animation];    animation.duration = 2;        if (direction != YES) {        index --;        NSLog(@"向右");        animation.type = @"oglFlip";//上下翻轉效果        animation.subtype = kCATransitionFromLeft;//方向向左            }else{        index ++;        NSLog(@"向左");        animation.type = @"cube";//立方體效果        animation.subtype = kCATransitionFromRight;    }        if (index<0) {        index = 6;    }    if (index>6) {        index = 0;    }        self.imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"社區%d.jpg",index+1]];    [self.imageView.layer addAnimation:animation forKey:@""];}@end

效果如下:

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.