92 lines
2.5 KiB
Swift
92 lines
2.5 KiB
Swift
//
|
|
// SPHomeTrendingCell.swift
|
|
// ShortPlay
|
|
//
|
|
// Created by 曾觉新 on 2025/4/14.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
class SPHomeTrendingCell: SPCollectionViewCell {
|
|
|
|
var model: SPShortModel? {
|
|
didSet {
|
|
coverImageView.sp_setImage(url: model?.image_url)
|
|
titleLabel.text = model?.name
|
|
}
|
|
}
|
|
|
|
private lazy var coverImageView: SPImageView = {
|
|
let imageView = SPImageView()
|
|
imageView.layer.cornerRadius = 10
|
|
imageView.layer.masksToBounds = true
|
|
return imageView
|
|
}()
|
|
|
|
private lazy var titleLabel: UILabel = {
|
|
let label = UILabel()
|
|
label.font = .fontLight(ofSize: 13)
|
|
label.textColor = .colorFFFFFF(alpha: 0.9)
|
|
label.numberOfLines = 2
|
|
return label
|
|
}()
|
|
|
|
private lazy var hotBgView: SPGradientView = {
|
|
let view = SPGradientView()
|
|
view.colors = [UIColor.colorF56490().cgColor, UIColor.colorBF6BFF().cgColor]
|
|
view.startPoint = .init(x: 0.5, y: 0)
|
|
view.endPoint = .init(x: 0.5, y: 1)
|
|
view.locations = [0, 1]
|
|
view.addRadius(topLeft: 0, topRight: 0, bottomLeft: 0, bottomRight: 6)
|
|
return view
|
|
}()
|
|
|
|
private lazy var hotIconImageView: UIImageView = {
|
|
let imageView = UIImageView(image: UIImage(named: "hot_icon_01"))
|
|
return imageView
|
|
}()
|
|
|
|
override init(frame: CGRect) {
|
|
super.init(frame: frame)
|
|
|
|
_setupUI()
|
|
}
|
|
|
|
@MainActor required init?(coder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
|
|
}
|
|
|
|
extension SPHomeTrendingCell {
|
|
|
|
private func _setupUI() {
|
|
contentView.addSubview(coverImageView)
|
|
contentView.addSubview(titleLabel)
|
|
coverImageView.addSubview(hotBgView)
|
|
hotBgView.addSubview(hotIconImageView)
|
|
|
|
coverImageView.snp.makeConstraints { make in
|
|
make.left.right.top.equalToSuperview()
|
|
make.bottom.equalToSuperview().offset(-38)
|
|
}
|
|
|
|
titleLabel.snp.makeConstraints { make in
|
|
make.left.equalToSuperview()
|
|
make.right.lessThanOrEqualToSuperview()
|
|
make.top.equalTo(coverImageView.snp.bottom).offset(5)
|
|
}
|
|
|
|
hotBgView.snp.makeConstraints { make in
|
|
make.left.top.equalToSuperview()
|
|
make.width.equalTo(22)
|
|
make.height.equalTo(16)
|
|
}
|
|
|
|
hotIconImageView.snp.makeConstraints { make in
|
|
make.center.equalToSuperview()
|
|
}
|
|
}
|
|
|
|
}
|