O2SearchHistoryCell.swift 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //
  2. // O2SearchHistoryCell.swift
  3. // O2Platform
  4. //
  5. // Created by FancyLou on 2021/5/24.
  6. // Copyright © 2021 zoneland. All rights reserved.
  7. //
  8. import UIKit
  9. class O2SearchHistoryCell: UICollectionViewCell {
  10. var title: UILabel?
  11. override init(frame: CGRect) {
  12. super.init(frame: frame)
  13. self.setUI()
  14. }
  15. required init?(coder: NSCoder) {
  16. fatalError("init(coder:) has not been implemented")
  17. }
  18. private func setUI() {
  19. self.title = UILabel()
  20. self.title!.backgroundColor = UIColor(hex: "#E6E6E6")
  21. self.title!.font = UIFont.systemFont(ofSize: 16)
  22. self.title!.layer.cornerRadius = 14.0
  23. self.title!.layer.masksToBounds = true
  24. self.title!.textAlignment = .center
  25. self.title!.textColor = UIColor(hex: "#333333")
  26. self.title!.text = ""
  27. self.contentView.addSubview(self.title!)
  28. }
  29. func setTitle(title: String) {
  30. print(title)
  31. self.title?.text = title
  32. self.title?.frame = CGRect(x: 0, y: 10, width: title.getSize(with: 16.0).width + 20, height: 28)
  33. }
  34. }