当前位置: 移动技术网 > IT编程>移动开发>IOS > iOS动画-定时对UIView进行翻转和抖动的方法

iOS动画-定时对UIView进行翻转和抖动的方法

2019年07月24日  | 移动技术网IT编程  | 我要评论

湖南卫视在线直播天天向上,合伙企业法全文,葫芦兄弟第二部全集

(翻转)方式一:

[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;
      // 切换界面保证动画不停止
      rotationanimation.removedoncompletion = no;
      rotationanimation.repeatcount = 1;
      [self.bindcardimageview.layer addanimation:rotationanimation forkey:@"rotationanimation"];
    }];

(翻转)方式二(这种方式较好一些):

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"];

抖动:

cabasicanimation* shake = [cabasicanimation animationwithkeypath:@"transform.rotation.z"];
  //设置抖动幅度
  shake.fromvalue = [nsnumber numberwithfloat:-0.2];
  shake.tovalue = [nsnumber numberwithfloat:+0.2];
  shake.duration = 0.1;
  shake.autoreverses = yes; //是否重复
  shake.repeatcount = 3;

  [itemview.iconimageview.layer addanimation:shake forkey:@"imageview"];

以上这篇ios动画-定时对uiview进行翻转和抖动的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持移动技术网。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网