QSLMineInfoView.swift 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. //
  2. // QSLMineInfoView.swift
  3. // QuickSearchLocation
  4. //
  5. // Created by Destiny on 2024/4/15.
  6. //
  7. import UIKit
  8. class QSLMineInfoView: UIView {
  9. lazy var infoAvatarImageView: UIImageView = {
  10. let imageView = UIImageView()
  11. imageView.image = UIImage(named: "mine_info_avatar")
  12. return imageView
  13. }()
  14. lazy var infoNameLabel: UILabel = {
  15. let label = UILabel()
  16. label.boldFont(18)
  17. label.textColor = QSLColor.Color_202020
  18. label.text = "54K55Ye755m75b2V".decode
  19. return label
  20. }()
  21. lazy var infoContentLabel: UILabel = {
  22. let label = UILabel()
  23. label.font(10)
  24. label.textColor = QSLColor.textColor_A7
  25. label.text = "解锁更多精彩内容"
  26. return label
  27. }()
  28. override init(frame: CGRect) {
  29. super.init(frame: frame)
  30. setUI()
  31. }
  32. required init?(coder: NSCoder) {
  33. fatalError("init(coder:) has not been implemented")
  34. }
  35. func config(name: String, content: String) {
  36. self.infoNameLabel.text = name
  37. self.infoContentLabel.text = content
  38. if(content == " 登录即享受会员权益 "){
  39. self.infoContentLabel.textColor = UIColor.hexStringColor(hexString: "#FF743A")
  40. self.infoContentLabel.backgroundColor = UIColor.hexStringColor(hexString: "#FFF5DA")
  41. self.infoContentLabel.layer.borderColor = UIColor.hexStringColor(hexString: "#FFDBA8").cgColor
  42. self.infoContentLabel.layer.borderWidth = 1
  43. self.infoContentLabel.layer.cornerRadius = 9.rpx
  44. self.infoContentLabel.layer.masksToBounds = true
  45. }else{
  46. self.infoContentLabel.textColor = QSLColor.textColor_A7
  47. self.infoContentLabel.backgroundColor = UIColor.clear
  48. self.infoContentLabel.layer.borderColor = UIColor.clear.cgColor
  49. self.infoContentLabel.layer.borderWidth = 1
  50. self.infoContentLabel.layer.cornerRadius = 9.rpx
  51. self.infoContentLabel.layer.masksToBounds = true
  52. }
  53. }
  54. }
  55. extension QSLMineInfoView {
  56. func setUI() {
  57. addSubview(infoAvatarImageView)
  58. addSubview(infoNameLabel)
  59. addSubview(infoContentLabel)
  60. infoAvatarImageView.snp.makeConstraints { make in
  61. make.left.equalTo(16.rpx)
  62. make.bottom.equalTo(-16.rpx)
  63. make.size.equalTo(CGSize(width: 56.rpx, height: 56.rpx))
  64. }
  65. infoNameLabel.snp.makeConstraints { make in
  66. make.height.equalTo(26.rpx)
  67. make.left.equalTo(infoAvatarImageView.snp.right).offset(12.rpx)
  68. make.top.equalTo(infoAvatarImageView.snp.top).offset(7.rpx)
  69. }
  70. infoContentLabel.snp.makeConstraints { make in
  71. make.height.equalTo(18.rpx)
  72. make.left.equalTo(infoAvatarImageView.snp.right).offset(12.rpx)
  73. make.top.equalTo(infoNameLabel.snp.bottom).offset(2.rpx)
  74. }
  75. }
  76. }