在imageView上,设置animationImages,来实现这个效果,项目中喇叭播放的效果就是这么实现的
- (UIImageView *)animationImageView {
if (!_animationImageView) {
_animationImageView = [[UIImageView alloc] init];
_animationImageView.frame = CGRectMake(self.recordButton.x - 42 - 31, (self.height - 31) / 2, 31, 31);
NSArray *images=[NSArray arrayWithObjects:[UIImage imageNamed:@"spoken_selfaudio_select_1"],[UIImage imageNamed:@"spoken_selfaudio_select_2"], nil];
_animationImageView.image = [UIImage imageNamed:@"spoken_selfaudio_select_1"];
//imageView的动画图片是数组images
_animationImageView.animationImages = images;
//按照原始比例缩放图片,保持纵横比
_animationImageView.contentMode = UIViewContentModeScaleAspectFit;
//切换动作的时间3秒,来控制图像显示的速度有多快,
_animationImageView.animationDuration = 0.5;
//动画的重复次数,想让它无限循环就赋成0
_animationImageView.animationRepeatCount = 0;
}
return _animationImageView;
}
开始动画
[self.animationImageView startAnimating];
结束动画
[self.animationImageView stopAnimating];
网友评论