// // QSLMineInfoView.swift // QuickSearchLocation // // Created by Destiny on 2024/4/15. // import UIKit class QSLMineInfoView: UIView { lazy var infoAvatarImageView: UIImageView = { let imageView = UIImageView() imageView.image = UIImage(named: "mine_info_avatar") return imageView }() lazy var infoNameLabel: UILabel = { let label = UILabel() label.boldFont(18) label.textColor = QSLColor.Color_202020 label.text = "54K55Ye755m75b2V".decode return label }() lazy var infoContentLabel: UILabel = { let label = UILabel() label.font(10) label.textColor = QSLColor.textColor_A7 label.text = "解锁更多精彩内容" return label }() override init(frame: CGRect) { super.init(frame: frame) setUI() } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } func config(name: String, content: String) { self.infoNameLabel.text = name self.infoContentLabel.text = content if(content == " 登录即享受会员权益 "){ self.infoContentLabel.textColor = UIColor.hexStringColor(hexString: "#FF743A") self.infoContentLabel.backgroundColor = UIColor.hexStringColor(hexString: "#FFF5DA") self.infoContentLabel.layer.borderColor = UIColor.hexStringColor(hexString: "#FFDBA8").cgColor self.infoContentLabel.layer.borderWidth = 1 self.infoContentLabel.layer.cornerRadius = 9.rpx self.infoContentLabel.layer.masksToBounds = true }else{ self.infoContentLabel.textColor = QSLColor.textColor_A7 self.infoContentLabel.backgroundColor = UIColor.clear self.infoContentLabel.layer.borderColor = UIColor.clear.cgColor self.infoContentLabel.layer.borderWidth = 1 self.infoContentLabel.layer.cornerRadius = 9.rpx self.infoContentLabel.layer.masksToBounds = true } } } extension QSLMineInfoView { func setUI() { addSubview(infoAvatarImageView) addSubview(infoNameLabel) addSubview(infoContentLabel) infoAvatarImageView.snp.makeConstraints { make in make.left.equalTo(16.rpx) make.bottom.equalTo(-16.rpx) make.size.equalTo(CGSize(width: 56.rpx, height: 56.rpx)) } infoNameLabel.snp.makeConstraints { make in make.height.equalTo(26.rpx) make.left.equalTo(infoAvatarImageView.snp.right).offset(12.rpx) make.top.equalTo(infoAvatarImageView.snp.top).offset(7.rpx) } infoContentLabel.snp.makeConstraints { make in make.height.equalTo(18.rpx) make.left.equalTo(infoAvatarImageView.snp.right).offset(12.rpx) make.top.equalTo(infoNameLabel.snp.bottom).offset(2.rpx) } } }