CMSItemTableViewCell.swift 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //
  2. // CMSItemTableViewCell.swift
  3. // O2Platform
  4. //
  5. // Created by 刘振兴 on 2016/12/8.
  6. // Copyright © 2016年 zoneland. All rights reserved.
  7. //
  8. import UIKit
  9. import CocoaLumberjack
  10. class CMSItemTableViewCell: UITableViewCell {
  11. @IBOutlet weak var itemIconImageView: UIImageView!
  12. @IBOutlet weak var titleLabel: UILabel!
  13. @IBOutlet weak var itemTimeLabel: UILabel!
  14. var itemData:CMSCategoryItemData? {
  15. didSet {
  16. //图像
  17. //let url = AppDelegate.o2Collect.generateURLWithAppContextKey(ContactContext.contactsContextKey, query: ContactContext.personIconByNameQuery, parameter: ["##name##":itemData?.creatorPerson as AnyObject])
  18. //self.itemIconImageView.af_setImage(withURL: URL(string: url!)!)
  19. //self.categoryLabel.text = "【\((itemData?.categoryName!)!)】"
  20. let urlstr = AppDelegate.o2Collect.generateURLWithAppContextKey(ContactContext.contactsContextKeyV2, query: ContactContext.personIconByNameQueryV2, parameter: ["##name##":itemData?.creatorPerson as AnyObject], generateTime: false)
  21. let url = URL(string: urlstr!)
  22. self.itemIconImageView.hnk_setImageFromURL(url!)
  23. self.titleLabel.text = itemData?.title
  24. if let publishTime = itemData?.publishTime {
  25. if let time = Date.date(publishTime, formatter: "yyyy-MM-dd HH:mm:ss") {
  26. self.itemTimeLabel.text = time.friendlyTime()
  27. }else {
  28. self.itemTimeLabel.text = publishTime
  29. }
  30. }else {
  31. self.itemTimeLabel.text = "Unknown"
  32. }
  33. }
  34. }
  35. override func awakeFromNib() {
  36. super.awakeFromNib()
  37. self.itemIconImageView.layer.cornerRadius = 15
  38. self.itemIconImageView.layer.masksToBounds = true
  39. }
  40. override func setSelected(_ selected: Bool, animated: Bool) {
  41. super.setSelected(selected, animated: animated)
  42. // Configure the view for the selected state
  43. }
  44. }