CNLiveMinePlayHistoryCollectionCell.swift 3.26 KB
//
//  CNLiveMinePlayHistoryCollectionCell.swift
//  metaCode
//
//  Created by zx on 2025/3/17.
//  播放记录列表cell

import Foundation
import Kingfisher

class CNLiveMinePlayHistoryCollectionCell: UICollectionViewCell {
    
    var num = 0//当前是第几
    var isJiShuSelected = false//是否选中

    var _followModel : CNLiveHomeFollowModel?
    var followModel : CNLiveHomeFollowModel? {
        get{
            _followModel
        }
        set{
            _followModel = newValue!
            self.setupNewUI(model: _followModel!)
        }
    }


    lazy var iconImgView :UIImageView = {
        let iconImgView = UIImageView(frame: CGRect(x: 0, y: 0, width: 165, height: 93))
        iconImgView.contentMode = .scaleAspectFill
        iconImgView.clipsToBounds = true
        iconImgView.layer.cornerRadius = 9
        iconImgView.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner]
        return iconImgView
    }()
    lazy var titleBgView :UIView = {
        let iconImgView = UIView(frame: CGRect(x: 0, y: self.iconImgView.height, width: self.iconImgView.width, height: 76))
        iconImgView.clipsToBounds = true
        iconImgView.layer.cornerRadius = 10
        iconImgView.layer.maskedCorners = [.layerMinXMaxYCorner, .layerMaxXMaxYCorner]
        iconImgView.backgroundColor = HexColor("#FAFAFA")
        return iconImgView
    }()
    lazy var titleLabel: UILabel = {
        let titleLbl = UILabel()
        titleLbl.font = BoldFont_14
        titleLbl.textColor = HexColor("#333333")
//        titleLbl.textAlignment = .center
        return titleLbl
    }()
    lazy var subTitleLabel: UILabel = {
        let titleLbl = UILabel()
        titleLbl.font = Font_12
        titleLbl.textColor = HexColor("#999999")
        titleLbl.numberOfLines = 2
//        titleLbl.textAlignment = .center
        return titleLbl
    }()

    
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.contentView.addSubview(self.iconImgView)
        self.contentView.addSubview(self.titleBgView)
        self.titleBgView.addSubview(self.titleLabel)
        self.titleBgView.addSubview(self.subTitleLabel)
        iconImgView.snp.makeConstraints { make in
            make.left.equalToSuperview()
            make.top.equalToSuperview()
            make.width.equalTo(165)
            make.height.equalTo(93)
        }
        titleBgView.snp.makeConstraints { make in
            make.left.equalToSuperview()
            make.top.equalTo(self.iconImgView.snp.bottom)
            make.width.equalTo(self.iconImgView.snp.width)
            make.bottom.equalToSuperview()
        }
        titleLabel.snp.makeConstraints { make in
            make.left.right.equalToSuperview()
            make.top.equalToSuperview().offset(10)
        }
        subTitleLabel.snp.makeConstraints { make in
            make.left.right.equalToSuperview()
            make.top.equalTo(self.titleLabel.snp.bottom).offset(3)
        }
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setupNewUI(model:CNLiveHomeFollowModel){
        self.iconImgView.kf.setImage(with: URL(string: model.poster))
        self.titleLabel.text = model.title
        self.subTitleLabel.text = model.description
    }
    
}