UnderLineTrainTableViewCell.swift 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //
  2. // UnderLineTrainTableViewCell.swift
  3. // xingchuangke
  4. //
  5. // Created by Virgil on 2019/5/13.
  6. // Copyright © 2019 Virgil. All rights reserved.
  7. //
  8. import UIKit
  9. class UnderLineTrainTableViewCell: UITableViewCell {
  10. @IBOutlet weak var viewContent: UIView!
  11. @IBOutlet weak var btnState: UIButton!
  12. @IBOutlet weak var lblName: UILabel!
  13. @IBOutlet weak var img: UIImageView!
  14. @IBOutlet weak var imgHeight: NSLayoutConstraint!
  15. override func awakeFromNib() {
  16. super.awakeFromNib()
  17. // Initialization code
  18. btnState.setCornerRadius(size: btnState.height() / 2)
  19. imgHeight.constant = (ScreenWidth - 48) / 327 * 121
  20. viewContent.setCornerRadius(size: 8)
  21. }
  22. func initCell(dic: NSDictionary) {
  23. img.loadImage(imgUrl: dic.getString(key: "image"), defaultImage: "")
  24. lblName.text = dic.getString(key: "title")
  25. let state = dic.getInt(key: "status")
  26. if state == 0 {
  27. btnState.setTitle("未开始", for: .normal)
  28. btnState.backgroundColor = CommonUntils.getUIColorFromRGB(rgbValue: 0x37a6ff, alpha: 1.0)
  29. } else if state == 1 {
  30. btnState.setTitle("进行中", for: .normal)
  31. btnState.backgroundColor = CommonUntils.getUIColorFromRGB(rgbValue: 0x37a6ff, alpha: 1.0)
  32. } else {
  33. btnState.setTitle("已结束", for: .normal)
  34. btnState.backgroundColor = CommonUntils.getUIColorFromRGB(rgbValue: 0xcccccc, alpha: 1.0)
  35. }
  36. }
  37. override func setSelected(_ selected: Bool, animated: Bool) {
  38. super.setSelected(selected, animated: animated)
  39. // Configure the view for the selected state
  40. }
  41. }