【代碼筆記】iOS-Transition動畫,筆記ios-transition

來源:互聯網
上載者:User

【代碼筆記】iOS-Transition動畫,筆記ios-transition

一,工程圖。

二,代碼。

RootViewController.h

#import <UIKit/UIKit.h>@interface RootViewController : UIViewController@end

 

RootViewController.m

#import "RootViewController.h"#import "FirstViewController.h"@interface RootViewController ()@end@implementation RootViewController- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];    if (self) {        // Custom initialization    }    return self;}- (void)viewDidLoad{    [super viewDidLoad];    // Do any additional setup after loading the view.            self.title=@"首頁";    self.view.backgroundColor=[UIColor redColor];            /* 過渡效果     fade     //交叉淡化過渡(不支援過渡方向)     push     //新視圖把舊視圖推出去     moveIn   //新視圖移到舊視圖上面     reveal   //將舊視圖移開,顯示下面的新視圖     cube     //立方體翻滾效果     oglFlip  //上下左右翻轉效果     suckEffect   //收縮效果,如一塊布被抽走(不支援過渡方向)     rippleEffect //滴水效果(不支援過渡方向)     pageCurl     //向上翻頁效果     pageUnCurl   //向下翻頁效果     cameraIrisHollowOpen  //相機鏡頭開啟效果(不支援過渡方向)     cameraIrisHollowClose //相機鏡頭關上效果(不支援過渡方向)     */        /* 過渡方向     fromRight;     fromLeft;     fromTop;     fromBottom;     */        }-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{           CATransition *transition = [CATransition animation];    // 動畫時間控制    transition.duration = 0.3f;    //動畫的開始與結束的快慢    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];    //是否代理    transition.delegate = self;    //此動畫執行完後會自動remove,預設值為true    transition.removedOnCompletion = NO;    //各種動畫效果    transition.type = kCATransitionMoveIn;    //動畫方向    transition.subtype = kCATransitionFromTop;        FirstViewController *viewCon = [[FirstViewController alloc]init];        [self.navigationController pushViewController:viewCon animated:NO];        // 想添加CA動畫的VIEW的層上添加此代碼    [self.navigationController.view.layer addAnimation:transition forKey:nil];}- (void)didReceiveMemoryWarning{    [super didReceiveMemoryWarning];    // Dispose of any resources that can be recreated.}

相關文章

聯繫我們

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