MyFileItemCell.swift 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //
  2. // MyFileItemCell.swift
  3. // O2Platform
  4. //
  5. // Created by 刘振兴 on 16/9/20.
  6. // Copyright © 2016年 zoneland. All rights reserved.
  7. //
  8. import UIKit
  9. class MyFileItemCell: UITableViewCell {
  10. @IBOutlet weak var iconImageView: UIImageView!
  11. @IBOutlet weak var nameLabel: UILabel!
  12. @IBOutlet weak var btnActionImageView: CellTouchImageView!
  13. var fileName:String? {
  14. didSet {
  15. self.nameLabel.text = fileName!
  16. let extName = fileName?.components(separatedBy: ".").last!
  17. self.iconImageView.image = UIImage(named: calcFileIcon(extName!))
  18. }
  19. }
  20. override func awakeFromNib() {
  21. super.awakeFromNib()
  22. // Initialization code
  23. }
  24. override func setSelected(_ selected: Bool, animated: Bool) {
  25. super.setSelected(selected, animated: animated)
  26. // Configure the view for the selected state
  27. }
  28. func calcFileIcon(_ ext:String) -> String{
  29. switch ext {
  30. case "doc","docx":
  31. return "file_doc_icon"
  32. case "xls","xlsx":
  33. return "file_excel_icon"
  34. case "ppt","pptx":
  35. return "file_ppt_icon"
  36. case "pdf":
  37. return "file_pdf_icon"
  38. case "rar","zip","war":
  39. return "file_compressFile_icon"
  40. case "txt":
  41. return "file_txt_icon"
  42. case "jpg","png","gif","jpeg":
  43. return "file_image_icon"
  44. default:
  45. return "file_unknown_icon"
  46. }
  47. }
  48. }