// // IHServiceRightItem.swift // Inhealth // // Created by weclouds on 2019/12/19. // Copyright © 2019 weclouds. All rights reserved. // import UIKit class IHServiceRightItem: UIView { var status : Bool? var title :String?{ didSet{ titleLabel.text = self.title } } private lazy var statusView: UIView = { let statusView = UIView() statusView.backgroundColor = UIColor(hexString: "#FF0C4D") return statusView }() private lazy var titleLabel: UILabel = { let label = UILabel() label.textColor = UIColor(hexString: "#333333") //label.backgroundColor = UIColor.cyan label.text = "High-risk" label.font = UIFont(name: Alibaba_PuHuiTi_Medium, size: 14) return label }() override init(frame: CGRect) { super.init(frame: frame) addSubview(statusView) addSubview(titleLabel) statusView.layer.cornerRadius = 2 statusView.layer.masksToBounds = true //customView自身的大小必须手动指定,不能使用自动布局来计算得出(但是customView的subview是可以使用自动布局的) statusView.frame = CGRect(x: 0, y: frame.size.height / 2 - 2, width: 4, height: 4) titleLabel.frame = CGRect(x: 7.5 + 4, y: 0, width: frame.size.width - 11.5, height: frame.size.height) } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } }