国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > 建站經驗 > 正文

iOS開、發:UIView的Animation效果

2019-11-02 14:13:55
字體:
來源:轉載
供稿:網友
扣扣網名[www.la240.com/html2017/1/18/]

   所謂動畫效果,就是會動的畫,到iOS App中來說的話,就是各種UIView的移動。 想想看,如果我們自己來實現所有UIView的動畫效果,需要考慮些什么東西呢?

  * 該UIView現在在哪兒?

  * 該UIView最后會動到哪兒?

  * 該UIView以什么樣的方式移動到那兒?

  * 該動畫持續多長時間?

  * 每次移動的最小時間間隔?

  * 每次最小時間間隔的移動的應該移動到哪兒?

  * ….

  想想這是一個多么殺腦細胞的過程,尤其是每一次的動畫過程都要重復這一折磨的過程。

  還好,現實比想象的美好, 蘋果公司為開發者思考了上面的問題,通過使用UIKit提供的動畫支持,開發者只需要簡單的幾行代碼就能實現各種各樣的動畫效果。在UIKit中,所有的動畫效果支持的方法都在UIView類中。

  首先,在UIView中有很多屬性用以描述一個UIView的狀態,而動畫就是讓UIView從一個狀態平滑的過渡到另外一個狀態的過程。這些屬性有:

iOS開發:UIView的Animation效果 電腦高手

  通過設置這些屬性,基本上就解決了動畫中的移動到哪兒的問題。

  接著,蘋果公司在UIView中加入很多方法來方便家控制動畫的移動時間,以及移動的方式。iOS3.0及之前,UIView支持的Animation方法有如下這么多:

  Object-c代碼

  @interface UIView(UIViewAnimation)

  + (void)beginAnimations:(NSString *)animationID context:(void *)context; // additional context info passed to will start/did stop selectors. begin/commit can be nested

  + (void)commitAnimations; // starts up any animations when the top level animation is commited

  // no getters. if called outside animation block, these setters have no effect.

  + (void)setAnimationDelegate:(id)delegate; // default = nil

  + (void)setAnimationWillStartSelector:(SEL)selector; // default = NULL. -animationWillStart:(NSString *)animationID context:(void *)context

  + (void)setAnimationDidStopSelector:(SEL)selector; // default = NULL. -animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context

  + (void)setAnimationDuration:(NSTimeInterval)duration; // default = 0.2

  + (void)setAnimationDelay:(NSTimeInterval)delay; // default = 0.0

  + (void)setAnimationStartDate:(NSDate *)startDate; // default = now ([NSDate date])

  + (void)setAnimationCurve:(UIViewAnimationCurve)curve; // default = UIViewAnimationCurveEaseInOut

  + (void)setAnimationRepeatCount:(float)repeatCount; // default = 0.0. May be fractional

  + (void)setAnimationRepeatAutoreverses:(BOOL)repeatAutoreverses; // default = NO. used if repeat count is non-zero

  + (void)setAnimationBeginsFromCurrentState:(BOOL)fromCurrentState; // default = NO. If YES, the current view position is always used for new animations -- allowing animations to "pile up" on each other. Otherwise, the last end state is used for the animation (the default).

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 名山县| 阜新市| 乌审旗| 神木县| 黎城县| 济阳县| 堆龙德庆县| 竹北市| 措勤县| 新昌县| 浙江省| 漠河县| 汾西县| 循化| 五原县| 巫山县| 宁武县| SHOW| 吴川市| 锡林郭勒盟| 宝山区| 乃东县| 夹江县| 裕民县| 景谷| 武清区| 隆尧县| 读书| 阿拉善右旗| 万荣县| 阿合奇县| 丘北县| 蕉岭县| 黄骅市| 黄冈市| 神农架林区| 台湾省| 江西省| 柞水县| 吉首市| 绥德县|