动画uibutton应用图像快速 [英] animate uibutton applying images swift

查看:88
本文介绍了动画uibutton应用图像快速的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过依次更改两个图像来应用动画效果。我已经应用了以下代码,但看不到动画效果。
我已经正确应用了IBOutlets。

I want to apply animation effect by changing two images on button turn by turn. I have applied following code but not able to see animation effect. I have applied IBOutlets properly.

    var image1:UIImage = UIImage(named: "img_mic_off")!
    var image2:UIImage = UIImage(named: "img_mic_on")!
    btnRecord.imageView?.animationImages = [image1,image1]
    btnRecord.imageView?.animationDuration = 1.0
    btnRecord.imageView!.startAnimating()

请帮助我解决为什么此给定代码无法使用的问题。谢谢。

Please help me to resolve issue that why it is not working with this given code. Thanks in advance.

推荐答案

检查一下我做了什么。图像正在改变。因此,我希望这是您真正需要的。

Check out what I've done. The images are changing. So I hope this is what you actually needed.

var image1:UIImage = UIImage(named: "img_mic_off")!
var image2:UIImage = UIImage(named: "img_mic_on")!
btn.setImage(image1, forState: UIControlState.Normal)
btn.imageView!.animationImages = [image1, image2]
btn.imageView!.animationDuration = 1.0
btn.imageView!.startAnimating()

这篇关于动画uibutton应用图像快速的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆