QSLHomeCallOutView.swift 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //
  2. // QSLHomeCallOutView.swift
  3. // QuickSearchLocation
  4. //
  5. // Created by Destiny on 2024/12/6.
  6. //
  7. import UIKit
  8. class MapLocationCalloutView: UIView {
  9. var name: String? {
  10. didSet {
  11. nameLabel.text = name
  12. let width = (name?.widthAccording(height: 20.rpx, font: UIFont.textM(14), lineSpacing: 0) ?? 0) + 16.rpx
  13. self.nameLabel.snp.updateConstraints { make in
  14. make.width.equalTo(width)
  15. }
  16. }
  17. }
  18. lazy var nameLabel: UILabel = {
  19. let label = UILabel()
  20. label.textAlignment = .center
  21. label.backgroundColor = .hexStringColor(hexString: "#000000", alpha: 0.7)
  22. label.addRadius(radius: 4.rpx)
  23. label.mediumFont(14)
  24. label.textColor = .white
  25. label.text = "11111"
  26. return label
  27. }()
  28. override init(frame: CGRect) {
  29. super.init(frame: frame)
  30. self.addSubview(self.nameLabel)
  31. self.nameLabel.snp.makeConstraints { make in
  32. make.center.equalToSuperview()
  33. make.height.equalTo(20.rpx)
  34. make.width.equalTo(30.rpx)
  35. }
  36. }
  37. required init?(coder: NSCoder) {
  38. fatalError("init(coder:) has not been implemented")
  39. }
  40. }