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

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

用_Animation實現iphone動畫效果

2019-11-02 14:50:17
字體:
來源:轉載
供稿:網友

  1、寫了一個小Demo,實現上下移動的效果圖:

 

  主要代碼如下:

  - (IBAction)upChange:(id)sender {

  if (typeView == down) {

  [self.downBtn setHidden:NO];

  [self.upBtn setHidden:NO];

  [UIView animateWithDuration:0.5 animations:^{

  self.upView.center = CGPointMake(self.upView.center.x, 0);

  self.downView.center = CGPointMake(self.downView.center.x, (self.upView.frame.size.height+self.downView.frame.size.height)/2);

  }];

  typeView = middle;

  }else if(typeView == middle){

  [self.downBtn setHidden:NO];

  [self.upBtn setHidden:YES];

  [UIView animateWithDuration:0.5 animations:^{

  self.upView.center = CGPointMake(self.upView.center.x, -(self.upView.frame.size.height/2));

  self.downView.center = CGPointMake(self.downView.center.x, self.downView.frame.size.height/2);

  }];

  typeView = up;

  }

  }

  - (IBAction)downChange:(id)sender {

  if (typeView == middle) {

  [self.downBtn setHidden:YES];

  [self.upBtn setHidden:NO];

  [UIView animateWithDuration:0.5 animations:^{

  self.upView.center = CGPointMake(self.upView.center.x, self.upView.frame.size.height/2);

  self.downView.center = CGPointMake(self.downView.center.x, self.upView.frame.size.height+self.downView.frame.size.height/2);

  }];

  typeView = down;

  }else if(typeView == up)

  {

  [self.downBtn setHidden:NO];

  [self.upBtn setHidden:NO];

  [UIView animateWithDuration:0.5 animations:^{

  self.upView.cen

YY4480首播影院[www.aikan.tv/special/YY4480shouboyingyuan/]
ter = CGPointMake(self.upView.center.x, 0);

  self.downView.center = CGPointMake(self.downView.center.x, (self.upView.frame.size.height+self.downView.frame.size.height)/2);

  }];

  typeView = middle;

  }

  }

  這是主要的代碼,另外還有一些需要注意的一些小細,如你的兩個view的大小,需要計算出精確位置。

  下面開始學習[UIView animateWithDuration]方法的使用:

  函數原型:

  + (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_4_0); // delay = 0.0, options = 0, completion = NULL

  duration:動畫持續時間

  animations:該代碼兒塊中是所有view要完成的動畫的所有屬性的定義;

  還有另外兩個函數:

  + (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_4_0);

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 九江县| 汽车| 宣化县| 如皋市| 横峰县| 赣榆县| 资源县| 社旗县| 共和县| 高唐县| 永寿县| 凤城市| 宣恩县| 彭阳县| 子洲县| 从化市| 星子县| 开鲁县| 丁青县| 建水县| 合山市| 淮滨县| 白沙| 临邑县| 电白县| 眉山市| 左贡县| 广河县| 太仆寺旗| 邵阳县| 双鸭山市| 烟台市| 墨玉县| 清镇市| 彭山县| 义乌市| 任丘市| 威海市| 南江县| 电白县| 通州市|