CommonPayCell.swift 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. //
  2. // CommonPayCell.swift
  3. // RainbowPlanet
  4. //
  5. // Created by Christopher on 2019/5/10.
  6. // Copyright © 2019 RainbowPlanet. All rights reserved.
  7. //
  8. import UIKit
  9. class CommonPayCell: UITableViewCell {
  10. var iconImageView: UIImageView = {
  11. let iconImageView = UIImageView()
  12. return iconImageView
  13. }()
  14. var titleLabel: UILabel = {
  15. let titleLabel = UILabel()
  16. titleLabel.textColor = k333333Color
  17. titleLabel.font = kRegularFont14
  18. titleLabel.textAlignment = .left
  19. return titleLabel
  20. }()
  21. var statusImageView: UIImageView = {
  22. let statusImageView = UIImageView()
  23. return statusImageView
  24. }()
  25. class func cellWith(tableView:UITableView,indexPath:IndexPath) -> CommonPayCell {
  26. let ID = "CommonPayCell"
  27. tableView.register(CommonPayCell.self, forCellReuseIdentifier: ID)
  28. let cell : CommonPayCell = tableView.dequeueReusableCell(withIdentifier: ID, for: indexPath) as! CommonPayCell
  29. cell.indexPath = indexPath
  30. return cell
  31. }
  32. override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
  33. super.init(style: style, reuseIdentifier: reuseIdentifier)
  34. setupViews()
  35. setupLayouts()
  36. }
  37. required init?(coder aDecoder: NSCoder) {
  38. fatalError("init(coder:) has not been implemented")
  39. }
  40. var indexPath: IndexPath? {
  41. didSet {
  42. }
  43. }
  44. //MRAK: - 设置View
  45. private func setupViews() {
  46. self.selectionStyle = .none
  47. addSubview(iconImageView)
  48. addSubview(titleLabel)
  49. addSubview(statusImageView)
  50. }
  51. private func setupLayouts() {
  52. iconImageView.snp.makeConstraints { (make) in
  53. make.left.equalToSuperview().offset(20)
  54. make.width.height.equalTo(20)
  55. make.centerY.equalToSuperview()
  56. }
  57. titleLabel.snp.makeConstraints { (make) in
  58. make.left.equalTo(iconImageView.snp_right).offset(10)
  59. make.height.equalTo(20)
  60. make.centerY.equalToSuperview()
  61. }
  62. statusImageView.snp.makeConstraints { (make) in
  63. make.right.equalToSuperview().offset(-20)
  64. make.width.height.equalTo(18)
  65. make.centerY.equalToSuperview()
  66. }
  67. }
  68. }