BBSSubjectAttachmentViewCell.swift 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. //
  2. // BBSSubjectAttachmentViewCell.swift
  3. // O2Platform
  4. //
  5. // Created by FancyLou on 2020/6/28.
  6. // Copyright © 2020 zoneland. All rights reserved.
  7. //
  8. import UIKit
  9. class BBSSubjectAttachmentViewCell: UITableViewCell {
  10. @IBOutlet weak var fileNameLabel: UILabel!
  11. @IBOutlet weak var typeImage: UIImageView!
  12. override func awakeFromNib() {
  13. super.awakeFromNib()
  14. // Initialization code
  15. }
  16. override func setSelected(_ selected: Bool, animated: Bool) {
  17. super.setSelected(selected, animated: animated)
  18. // Configure the view for the selected state
  19. }
  20. func setAttachment(file: O2BBSSubjectAttachmentInfo) {
  21. self.fileNameLabel.text = file.name
  22. self.setFileTypeImage(ext: file.ext)
  23. }
  24. private func setFileTypeImage(ext: String?) {
  25. if let type = ext {
  26. switch type {
  27. case "jpg", "png", "jepg", "gif":
  28. self.typeImage.image = UIImage(named: "icon_img")
  29. break
  30. case "html":
  31. self.typeImage.image = UIImage(named: "icon_html")
  32. break
  33. case "xls", "xlsx":
  34. self.typeImage.image = UIImage(named: "icon_excel")
  35. break
  36. case "doc", "docx":
  37. self.typeImage.image = UIImage(named: "icon_word")
  38. break
  39. case "ppt", "pptx":
  40. self.typeImage.image = UIImage(named: "icon_ppt")
  41. break
  42. case "pdf":
  43. self.typeImage.image = UIImage(named: "icon_pdf")
  44. break
  45. case "mp4":
  46. self.typeImage.image = UIImage(named: "icon_mp4")
  47. break
  48. case "mp3":
  49. self.typeImage.image = UIImage(named: "icon_mp3")
  50. break
  51. case "zip", "rar", "7z":
  52. self.typeImage.image = UIImage(named: "icon_zip")
  53. break
  54. default :
  55. self.typeImage.image = UIImage(named: "icon_moren")
  56. break
  57. }
  58. }else {
  59. self.typeImage.image = UIImage(named: "icon_moren")
  60. }
  61. }
  62. }