// 設置按鈕圖片動畫數組
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 高仿微信動畫