QSLMineFuncCollectionViewCell.swift 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. //
  2. // QSLMineFuncTableViewCell.swift
  3. // QuickSearchLocation
  4. //
  5. // Created by Destiny on 2024/4/16.
  6. //
  7. import UIKit
  8. class QSLMineFuncTableViewCell: UITableViewCell {
  9. var cellDict:[String: String]? {
  10. didSet {
  11. updateUI()
  12. }
  13. }
  14. lazy var cellIcon: UIImageView = {
  15. let imageView = UIImageView()
  16. imageView.image = UIImage(named: "")
  17. return imageView
  18. }()
  19. lazy var cellLabel: UILabel = {
  20. let label = UILabel()
  21. label.font(15)
  22. label.textColor = QSLColor.Color_202020
  23. return label
  24. }()
  25. lazy var arrowIcon: UIImageView = {
  26. let imageView = UIImageView()
  27. imageView.image = UIImage(named: "mine_func_arrow")
  28. return imageView
  29. }()
  30. override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
  31. super.init(style: style, reuseIdentifier: reuseIdentifier)
  32. setUpUI()
  33. }
  34. required init?(coder: NSCoder) {
  35. fatalError("init(coder:) has not been implemented")
  36. }
  37. }
  38. extension QSLMineFuncTableViewCell {
  39. func updateUI() {
  40. if let dict = self.cellDict {
  41. let image = UIImage(named: dict["image"] ?? "")
  42. self.cellIcon.image = image
  43. self.cellLabel.text = dict["title"]
  44. }
  45. }
  46. func setUpUI() {
  47. addSubview(cellIcon)
  48. addSubview(cellLabel)
  49. addSubview(arrowIcon)
  50. cellIcon.snp.makeConstraints { make in
  51. make.left.equalTo(12.rpx)
  52. make.centerY.equalToSuperview()
  53. make.size.equalTo(CGSize(width: 24.rpx, height: 24.rpx))
  54. }
  55. cellLabel.snp.makeConstraints { make in
  56. make.centerY.equalToSuperview()
  57. make.left.equalTo(cellIcon.snp.right).offset(8.rpx)
  58. }
  59. arrowIcon.snp.makeConstraints { make in
  60. make.centerY.equalToSuperview()
  61. make.right.equalTo(-12.rpx)
  62. }
  63. }
  64. }