欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

iOS動(dòng)畫(huà)-定時(shí)對(duì)UIView進(jìn)行翻轉(zhuǎn)和抖動(dòng)的方法

 更新時(shí)間:2017年04月23日 10:33:17   投稿:jingxian  
下面小編就為大家?guī)?lái)一篇iOS動(dòng)畫(huà)-定時(shí)對(duì)UIView進(jìn)行翻轉(zhuǎn)和抖動(dòng)的方法。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧

(翻轉(zhuǎn))方式一:

[NSTimer scheduledTimerWithTimeInterval:3.f repeats:YES block:^(NSTimer * _Nonnull timer) {
      CABasicAnimation* rotationAnimation = [CABasicAnimation animation];;
      rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.y"];
      rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 ];
      rotationAnimation.duration = 1;
      // 切換界面保證動(dòng)畫(huà)不停止
      rotationAnimation.removedOnCompletion = NO;
      rotationAnimation.repeatCount = 1;
      [self.bindCardImageView.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
    }];

(翻轉(zhuǎn))方式二(這種方式較好一些):

CABasicAnimation *waitAnimation = [CABasicAnimation animation];
    waitAnimation.toValue = [NSNumber numberWithFloat:1.0];
    waitAnimation.duration = 3.f;
    waitAnimation.beginTime = 3.f;

    CABasicAnimation* rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.y"];
    rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 ];
    rotationAnimation.duration = 1.f;

    CAAnimationGroup *group = [CAAnimationGroup animation];
    group.duration = 4.f;
    group.repeatCount = CGFLOAT_MAX;
    group.removedOnCompletion = NO;

    [group setAnimations:@[waitAnimation, rotationAnimation]];

    [self.bindCardImageView.layer addAnimation:group forKey:@"bindCardImageViewAnimation"];

抖動(dòng):

CABasicAnimation* shake = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
  //設(shè)置抖動(dòng)幅度
  shake.fromValue = [NSNumber numberWithFloat:-0.2];
  shake.toValue = [NSNumber numberWithFloat:+0.2];
  shake.duration = 0.1;
  shake.autoreverses = YES; //是否重復(fù)
  shake.repeatCount = 3;

  [itemView.iconImageView.layer addAnimation:shake forKey:@"imageView"];

以上這篇iOS動(dòng)畫(huà)-定時(shí)對(duì)UIView進(jìn)行翻轉(zhuǎn)和抖動(dòng)的方法就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論