81 lines
2.0 KiB
Swift
81 lines
2.0 KiB
Swift
//
|
|
// SPHomeShortsForYouCell.swift
|
|
// ShortPlay
|
|
//
|
|
// Created by 曾觉新 on 2025/4/14.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
class SPHomeShortsForYouCell: SPCollectionViewCell {
|
|
|
|
|
|
var model: SPShortModel? {
|
|
didSet {
|
|
coverImageView.sp_setImage(url: model?.horizontally_img)
|
|
titleLabel.text = model?.name
|
|
}
|
|
}
|
|
|
|
private lazy var coverImageView: SPImageView = {
|
|
let imageView = SPImageView()
|
|
return imageView
|
|
}()
|
|
|
|
private lazy var bottomView: SPGradientView = {
|
|
let view = SPGradientView()
|
|
view.colors = [UIColor.color121418(alpha: 0).cgColor, UIColor.color121418(alpha: 0.8).cgColor]
|
|
view.startPoint = CGPoint(x: 0.5, y: 0)
|
|
view.endPoint = CGPoint(x: 0.5, y: 1)
|
|
view.locations = [0, 1]
|
|
return view
|
|
}()
|
|
|
|
private lazy var titleLabel: UILabel = {
|
|
let label = UILabel()
|
|
label.font = .fontLight(ofSize: 14)
|
|
label.textColor = .colorFFFFFF(alpha: 0.9)
|
|
return label
|
|
}()
|
|
|
|
override init(frame: CGRect) {
|
|
super.init(frame: frame)
|
|
|
|
contentView.layer.cornerRadius = 12
|
|
contentView.layer.masksToBounds = true
|
|
|
|
_setupUI()
|
|
}
|
|
|
|
@MainActor required init?(coder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
|
|
}
|
|
|
|
extension SPHomeShortsForYouCell {
|
|
|
|
private func _setupUI() {
|
|
contentView.addSubview(coverImageView)
|
|
contentView.addSubview(bottomView)
|
|
contentView.addSubview(titleLabel)
|
|
|
|
coverImageView.snp.makeConstraints { make in
|
|
make.edges.equalToSuperview()
|
|
}
|
|
|
|
bottomView.snp.makeConstraints { make in
|
|
make.left.right.bottom.equalToSuperview()
|
|
make.height.equalTo(65)
|
|
}
|
|
|
|
titleLabel.snp.makeConstraints { make in
|
|
make.left.equalToSuperview().offset(7)
|
|
make.bottom.equalToSuperview().offset(-12)
|
|
make.right.lessThanOrEqualToSuperview().offset(-7)
|
|
}
|
|
|
|
}
|
|
|
|
}
|