iOS 几行代码实现图片动画(微信语音动画、加载动画)等等
2018-04-24 本文已影响27人
键盘上的演绎者
UIImageView *animationView = [[UIImageView alloc]initWithFrame:CGRectMake(40, 22.5, 15, 15)];
//未开始的图片
animationView.image = [UIImage imageNamed:@"icon_animation_01"];
//动画效果图片(按照播放顺序放置)
animationView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"icon_animation_01"],
[UIImage imageNamed:@"icon_animation_02"],
[UIImage imageNamed:@"icon_animation_03"],nil];
//设置动画间隔
animationView.animationDuration = 1;
animationView.animationRepeatCount = 0;
animationView.userInteractionEnabled = NO;
animationView.backgroundColor = [UIColor clearColor];
[self.view addSubview:animationView];
//开始动画
[animationView startAnimating];
//结束动画
[animationView stopAnimating];