//
//  MVBannerUsageView.swift
//  MusicVideoPlus
//
//  Created by Harry Hu on 2021/10/8.
//

import Foundation

class MVBannerUsageView: UIView {
    var amount:Int = 0 {
        didSet {
            contentL.text = "使用量 \(amount)"
            contentL.sizeToFit()
        }
    }    // 使用量
    
    lazy var contentL:UILabel = {
        let contentL = UILabel(frame: .zero)
        contentL.textColor = UIColor.white
        contentL.font = UIFont(name: "PingFangSC-Regular", size: 12)
        contentL.textAlignment = .left
        contentL.text = "使用量 0"
        return contentL
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        self.backgroundColor = .clear
        
        let backV = UIView()
        backV.backgroundColor = UIColor.black
        backV.alpha = 0.3
        backV.layer.cornerRadius = 5
        addSubview(backV)
        backV.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        let iconIV = UIImageView(image: UIImage(named: "people"))
        iconIV.frame = CGRect(x: 6, y: 7, width: 12, height: 12)
        addSubview(iconIV)
        
        
        addSubview(contentL)
        
        contentL.snp.makeConstraints { make in
            make.left.equalTo(iconIV.snp.right).offset(6.5)
            make.top.bottom.equalToSuperview()
            make.right.equalToSuperview().offset(-6).priorityHigh()
        }

    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
//    override func layoutSubviews() {
//        super.layoutSubviews()
//        self.layer.backgroundColor = UIColor.black.cgColor
//        self.layer.cornerRadius = 5
//    }
}
