iOS的動畫效果類型及實現方法,ios動畫類型實現

來源:互聯網
上載者:User

iOS的動畫效果類型及實現方法,ios動畫類型實現

實現iOS漂亮的動畫效果主要有兩種方法,

   一種是UIView層面的,

  一種是使用CATransition進行更低層次的控制,

 

      第一種是UIView,UIView方式可能在低層也是使用CATransition進行了封裝,它只能用於一些簡單的、常用的效果展現,這裡寫一個常用的範例程式碼,供大家參考。

 

 [UIView beginAnimations:@"Curl"context:nil];//動畫開始  [UIView setAnimationDuration:0.75];  [UIView setAnimationDelegate:self]; [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:myview cache:YES]; [myview removeFromSuperview]; [UIView commitAnimations]; 

 

       第二種方式相對複雜一些,但如果更好的進行控制,還是使用這種方法吧,

基本使用方法可以看一下如下例子:

 

CATransition *animation = [CATransition animation];[animation setDuration:1.25f]; [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]]; [animation setType:kCATransitionReveal];[animation setSubtype: kCATransitionFromBottom];[self.view.layer addAnimation:animation forKey:@"Reveal"]; 

這裡使用了setType與setSubtype組合,這使用個比較保險,因為他的參數就是官方API裡定義的,他們的參數說明可以參考如下:

 

[animation setType:@"suckEffect"];

這裡的suckEffect就是效果名稱,可以用的效果主要有:

  pageCurl 向上翻一頁   pageUnCurl 向下翻一頁   rippleEffect 滴水效果   suckEffect 收縮效果,如一塊布被抽走   cube 立方體效果   oglFlip 上下翻轉效果  

最後再給出一種常用代碼供大家參考。

// Curl the image up or down  CATransition *animation = [CATransition animation]; [animation setDuration:0.35]; [animation setTimingFunction:UIViewAnimationCurveEaseInOut];  if (!curled)   {        //animation.type = @"mapCurl";          animation.type = @"pageCurl";         animation.fillMode = kCAFillModeForwards;          animation.endProgress = 0.99;    } else {       //animation.type = @"mapUnCurl";        animation.type = @"pageUnCurl";        animation.fillMode = kCAFillModeBackwards; animation.startProgress = 0.01;  }  [animation setRemovedOnCompletion:NO];[view exchangeSubviewAtIndex:0 withSubviewAtIndex:1]; [view addAnimation:animation forKey"pageCurlAnimation"]; // Disable user interaction where necessary  if (!curled) { }   else {   }  curled = !curled;
用ios怎實作類別似百度影音的介面 就是文字的淡入淡出的動畫 先

你是要搞ios開發嗎?還是別的東東?文字的淡入淡出可以修改label的透明度,然後做動畫就可以了。不知道是我說的這樣不?
 
iOS開發中使用pop可以製作翻頁動畫

不知道你的翻頁動畫想要哪種效果。
就普通的CurlUp之類的動畫效果Apple內建的api就能實現。
facebook pop動畫引擎區別於Apple內建的api的最主要的地方是:pop能提供新的動態特效spring和decay, 可以讓視覺效果更酷。
非要用pop也能實現CurlUp之類的效果。
 

聯繫我們

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