iOS动画-定时对UIView进行翻转和抖动的方法
(翻转)方式一:
[NSTimerscheduledTimerWithTimeInterval:3.frepeats:YESblock:^(NSTimer*_Nonnulltimer){
CABasicAnimation*rotationAnimation=[CABasicAnimationanimation];;
rotationAnimation=[CABasicAnimationanimationWithKeyPath:@"transform.rotation.y"];
rotationAnimation.toValue=[NSNumbernumberWithFloat:M_PI*2.0];
rotationAnimation.duration=1;
//切换界面保证动画不停止
rotationAnimation.removedOnCompletion=NO;
rotationAnimation.repeatCount=1;
[self.bindCardImageView.layeraddAnimation:rotationAnimationforKey:@"rotationAnimation"];
}];
(翻转)方式二(这种方式较好一些):
CABasicAnimation*waitAnimation=[CABasicAnimationanimation]; waitAnimation.toValue=[NSNumbernumberWithFloat:1.0]; waitAnimation.duration=3.f; waitAnimation.beginTime=3.f; CABasicAnimation*rotationAnimation=[CABasicAnimationanimationWithKeyPath:@"transform.rotation.y"]; rotationAnimation.toValue=[NSNumbernumberWithFloat:M_PI*2.0]; rotationAnimation.duration=1.f; CAAnimationGroup*group=[CAAnimationGroupanimation]; group.duration=4.f; group.repeatCount=CGFLOAT_MAX; group.removedOnCompletion=NO; [groupsetAnimations:@[waitAnimation,rotationAnimation]]; [self.bindCardImageView.layeraddAnimation:groupforKey:@"bindCardImageViewAnimation"];
抖动:
CABasicAnimation*shake=[CABasicAnimationanimationWithKeyPath:@"transform.rotation.z"]; //设置抖动幅度 shake.fromValue=[NSNumbernumberWithFloat:-0.2]; shake.toValue=[NSNumbernumberWithFloat:+0.2]; shake.duration=0.1; shake.autoreverses=YES;//是否重复 shake.repeatCount=3; [itemView.iconImageView.layeraddAnimation:shakeforKey:@"imageView"];
以上这篇iOS动画-定时对UIView进行翻转和抖动的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持毛票票。
热门推荐
1 训练狗狗憋尿
2 狗狗追踪训练
3 狗狗训练要多少钱
5 深圳狗狗训练
6 训练狗狗唤回
7 狗狗叫怎么训练
8 狗狗训练班
10 狗狗社会化训练
11 狗狗叫回训练
12 广州狗狗训练学校
13 狗狗训练躺下
14 狗狗随行训练
15 训练狗狗巡回
16 狗狗要怎么训练
17 狗狗喂食训练
18 训练狗狗躺下