// // SPHomeExploreCell.swift // MoviaBox // // Created by Overseas on 2025/4/22. // import UIKit class SPHomeExploreCell: SPCollectionViewCell { var model: SPShortModel? { didSet { coverImageView.sp_setImage(url: model?.image_url) titleLabel.text = model?.name if model?.tag_type == .hot { markView.isHidden = false markView.colors = [UIColor.color3E23DE(alpha: 0.17).cgColor, UIColor.color4629F1(alpha: 0.74).cgColor, UIColor.color3D1DFF().cgColor] markLabel.text = "HOT" } else if model?.tag_type == .new { markView.isHidden = false markView.colors = [UIColor.colorDE2326(alpha: 0.17).cgColor, UIColor.colorF1298A(alpha: 0.74).cgColor, UIColor.colorFF1DE8().cgColor] markLabel.text = "NEW" } else { markView.isHidden = true } } } //MARK: UI属性 private lazy var coverImageView: SPImageView = { let imageView = SPImageView() imageView.layer.cornerRadius = 4 imageView.layer.masksToBounds = true return imageView }() private lazy var markView: SPGradientView = { let view = SPGradientView() view.locations = [0, 0.3, 1] view.startPoint = .init(x: 0, y: 0.7) view.endPoint = .init(x: 1, y: 0.5) view.addRadius(topLeft: 0, topRight: 0, bottomLeft: 12, bottomRight: 0) return view }() private lazy var markLabel: UILabel = { let label = UILabel() label.font = .fontBold(ofSize: 12) label.textColor = .colorFFFFFF() return label }() private lazy var titleLabel: UILabel = { let label = UILabel() label.font = .fontRegular(ofSize: 12) label.textColor = .colorFFFFFF() label.numberOfLines = 2 return label }() override init(frame: CGRect) { super.init(frame: frame) _setupUI() } @MainActor required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } } extension SPHomeExploreCell { private func _setupUI() { contentView.addSubview(coverImageView) coverImageView.addSubview(markView) markView.addSubview(markLabel) contentView.addSubview(titleLabel) coverImageView.snp.makeConstraints { make in make.left.right.top.equalToSuperview() make.bottom.equalToSuperview().offset(-36) } markView.snp.makeConstraints { make in make.top.equalToSuperview() make.right.equalToSuperview() make.width.equalTo(46) make.height.equalTo(18) } markLabel.snp.makeConstraints { make in make.center.equalToSuperview() } titleLabel.snp.makeConstraints { make in make.left.equalToSuperview() make.right.lessThanOrEqualToSuperview() make.top.equalTo(coverImageView.snp.bottom).offset(8) } } }