IHServiceRightItem.swift 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. //
  2. // IHServiceRightItem.swift
  3. // Inhealth
  4. //
  5. // Created by weclouds on 2019/12/19.
  6. // Copyright © 2019 weclouds. All rights reserved.
  7. //
  8. import UIKit
  9. class IHServiceRightItem: UIView {
  10. var status : Bool?
  11. var title :String?{
  12. didSet{
  13. titleLabel.text = self.title
  14. }
  15. }
  16. private lazy var statusView: UIView = {
  17. let statusView = UIView()
  18. statusView.backgroundColor = UIColor(hexString: "#FF0C4D")
  19. return statusView
  20. }()
  21. private lazy var titleLabel: UILabel = {
  22. let label = UILabel()
  23. label.textColor = UIColor(hexString: "#333333")
  24. //label.backgroundColor = UIColor.cyan
  25. label.text = "High-risk"
  26. label.font = UIFont(name: Alibaba_PuHuiTi_Medium, size: 14)
  27. return label
  28. }()
  29. override init(frame: CGRect) {
  30. super.init(frame: frame)
  31. addSubview(statusView)
  32. addSubview(titleLabel)
  33. statusView.layer.cornerRadius = 2
  34. statusView.layer.masksToBounds = true
  35. //customView自身的大小必须手动指定,不能使用自动布局来计算得出(但是customView的subview是可以使用自动布局的)
  36. statusView.frame = CGRect(x: 0, y: frame.size.height / 2 - 2, width: 4, height: 4)
  37. titleLabel.frame = CGRect(x: 7.5 + 4, y: 0, width: frame.size.width - 11.5, height: frame.size.height)
  38. }
  39. required init?(coder: NSCoder) {
  40. fatalError("init(coder:) has not been implemented")
  41. }
  42. }