IMAudioView.swift 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //
  2. // IMAudioView.swift
  3. // O2Platform
  4. //
  5. // Created by FancyLou on 2020/6/17.
  6. // Copyright © 2020 zoneland. All rights reserved.
  7. //
  8. import UIKit
  9. class IMAudioView: UIView {
  10. static let IMAudioView_width: CGFloat = 92
  11. static let IMAudioView_height: CGFloat = 28
  12. @IBOutlet weak var playImageView: UIImageView!
  13. @IBOutlet weak var durationLabel: UILabel!
  14. override func awakeFromNib() { }
  15. func setDuration(duration: String) {
  16. self.durationLabel.text = "\(duration)\""
  17. }
  18. /// 设置gif图片 进行播放
  19. func playAudioGif() {
  20. let url: URL? = Bundle.main.url(forResource: "chat_play_left", withExtension: "gif")
  21. guard let u = url else {
  22. return
  23. }
  24. guard let data = try? Data.init(contentsOf: u) else {
  25. return
  26. }
  27. playImageView.image = UIImage.sd_animatedGIF(with: data)
  28. }
  29. /// 设置静态图片
  30. func stopPlayAudioGif() {
  31. playImageView.image = UIImage(named: "chat_play_left_s")
  32. }
  33. }