iOS 实现图片抖动效果

代码实现

创建定时器

_timer=[NSTimer scheduledTimerWithTimeInterval:1.5 target:self selector:@selector(doudongAnimation) userInfo:nil repeats:YES];

动画实现

-(void)doudongAnimation{ CABasicAnimation* shake = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; //设置抖动幅度 shake.fromValue = [NSNumber numberWithFloat:-0.1]; shake.toValue = [NSNumber numberWithFloat:+0.1]; shake.duration = 0.1; shake.autoreverses = YES; //是否重复 shake.repeatCount = 4; [self.smallImgView.layer addAnimation:shake forKey:@"smallImgView"]; self.smallImgView.alpha = 1.0; [UIView animateWithDuration:2.0 delay:2.0 options:UIViewAnimationOptionCurveEaseIn animations:nil completion:nil]; }
·

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容