// 设置按钮图片动画数组
voiceButton.imageView?.animationImages = [
#imageLiteral(resourceName: "message_voice_sender_playing_1"),
#imageLiteral(resourceName: "message_voice_sender_playing_2"),
#imageLiteral(resourceName: "message_voice_sender_playing_3")
]
复制代码
// 开始动画
voiceButton.imageView?.startAnimating()
复制代码
// 中止动画
voiceButton.imageView?.stopAnimating()
复制代码
这个按钮在结束动画以后之因此会变暗,是由于它在动画结束以后自动显示为高亮图片,不信?那只好上证据了~git
// 设置语音按钮的高亮图片
voiceButton.setImage(#imageLiteral(resourceName: "message_voice_sender_normal"), for: .highlighted)
复制代码
那知道缘由以后就很好解决了github
将按钮的高亮图片与普通状态下的一致便可。这里就再赘述了swift
在UIButton中有这么一个属性数组
adjustsImageWhenHighlighted
复制代码
查看官方文档的说明 微信
附上相关项目:Swift 3.0 高仿微信动画