99 lines
2.5 KiB
Swift
99 lines
2.5 KiB
Swift
//
|
|
// SPHomeDataItemView.swift
|
|
// MoviaBox
|
|
//
|
|
// Created by 曾觉新 on 2025/4/14.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
class SPHomeDataItemView: UIView {
|
|
|
|
///内容距离顶部位置
|
|
static let contentToTop: CGFloat = 32
|
|
|
|
|
|
class func contentHeight(dataArr: [SPShortModel]) -> CGFloat {
|
|
return contentToTop
|
|
}
|
|
|
|
override var intrinsicContentSize: CGSize {
|
|
let height = Self.contentHeight(dataArr: dataArr ?? [])
|
|
return CGSize(width: kSPScreenWidth, height: height)
|
|
}
|
|
|
|
var dataArr: [SPShortModel]? {
|
|
didSet {
|
|
self.invalidateIntrinsicContentSize()
|
|
}
|
|
}
|
|
|
|
private(set) lazy var titleLabel: UILabel = {
|
|
let label = UILabel()
|
|
label.font = .fontWeight(ofSize: 18, weight: 400)
|
|
label.textColor = .colorFFFFFF()
|
|
return label
|
|
}()
|
|
|
|
private(set) lazy var iconImageView: UIImageView = {
|
|
let imageView = UIImageView()
|
|
return imageView
|
|
}()
|
|
|
|
private lazy var moreButton: UIButton = {
|
|
let button = UIButton(type: .custom)
|
|
button.setTitle("movia_more".localized, for: .normal)
|
|
button.setTitleColor(.colorF564B6(), for: .normal)
|
|
button.titleLabel?.font = .fontLight(ofSize: 12)
|
|
return button
|
|
}()
|
|
|
|
private(set) lazy var contentView: UIView = {
|
|
let view = UIView()
|
|
return view
|
|
}()
|
|
|
|
override init(frame: CGRect) {
|
|
super.init(frame: frame)
|
|
|
|
_setupUI()
|
|
}
|
|
|
|
required init?(coder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
|
|
}
|
|
|
|
extension SPHomeDataItemView {
|
|
|
|
private func _setupUI() {
|
|
addSubview(titleLabel)
|
|
addSubview(iconImageView)
|
|
// addSubview(moreButton)
|
|
addSubview(contentView)
|
|
|
|
titleLabel.snp.makeConstraints { make in
|
|
make.left.equalToSuperview().offset(16)
|
|
make.top.equalToSuperview()
|
|
make.height.equalTo(21)
|
|
}
|
|
|
|
iconImageView.snp.makeConstraints { make in
|
|
make.centerY.equalTo(titleLabel)
|
|
make.left.equalTo(titleLabel.snp.right).offset(8)
|
|
}
|
|
|
|
// moreButton.snp.makeConstraints { make in
|
|
// make.centerY.equalTo(titleLabel)
|
|
// make.right.equalToSuperview().offset(-15)
|
|
// }
|
|
|
|
contentView.snp.makeConstraints { make in
|
|
make.left.right.bottom.equalToSuperview()
|
|
make.top.equalTo(Self.contentToTop)
|
|
}
|
|
}
|
|
|
|
}
|