iOS中微信语音动画

作者: Hither | 来源:发表于2016-04-01 12:59 被阅读3012次

做项目的遇到这样一个需求,模仿微信的语音消息,点击以后有波纹扩散效果。

代码很简单 几句话就可以搞定,下面是代码:

UIImageView *voice = [[UIImageView alloc]initWithFrame:CGRectMake(40, 22.5, 15, 15)];
//动画未开始前的图片
voice.image = [UIImage imageNamed:@"chat_animation_white3"];
//进行动画效果的3张图片(按照播放顺序放置)
        voice.animationImages = [NSArray arrayWithObjects:
                                      [UIImage imageNamed:@"chat_animation_white1"],
                                      [UIImage imageNamed:@"chat_animation_white2"],
                                      [UIImage imageNamed:@"chat_animation_white3"],nil];
//设置动画间隔
        voice.animationDuration = 1;
        voice.animationRepeatCount = 0;
        voice.userInteractionEnabled = NO;
        voice.backgroundColor = [UIColor clearColor];
        
        [self.view addSubview:voice];

相关文章

网友评论

  • catcherdream:亲,这是一开始拒设置好的,还是在点击事件里加?
    Hither:@我就叫Tom怎么了 是的
    我就叫Tom怎么了:@有味道的简书 是在点击事件里调用[voice startAnimating];和[voice stopAnimating];么?写上吧,像我这种新手看不懂:smile:
    Hither:@catcherdream 一开始初始化的

本文标题:iOS中微信语音动画

本文链接:https://www.haomeiwen.com/subject/rvlylttx.html