//
//  MPPositive_CustomTabBarItem.swift
//  MusicPlayer
//
//  Created by Mr.Zhou on 2024/4/19.
//

import UIKit
///b面tabBarItem
class MPPositive_CustomTabBarItem: UIView {
    ///icon图片
    fileprivate lazy var iconImageView:UIImageView = {
        let imageView:UIImageView = .init()
        imageView.contentMode = .scaleAspectFill
        return imageView
    }()
    ///选中圆圈（选中状态显示）
    private lazy var circleImageView:UIImageView = {
        let imageView:UIImageView = .init()
        imageView.image = UIImage(named: "B_Circle")
        imageView.contentMode = .scaleAspectFill
        return imageView
    }()
    ///展示的内容
    var title:String!{
        didSet{
            iconImageView.image = UIImage(named: title)
        }
    }
    ///选中状态
    var isSelected:Bool = false{
        didSet{
            if isSelected {
                //选中
                iconImageView.image = UIImage(named: title + " 1")
                circleImageView.isHidden = false
            }else{
                //未选中
                iconImageView.image = UIImage(named: title)
                circleImageView.isHidden = true
            }
        }
    }
    override init(frame: CGRect) {
        super.init(frame: frame)
        confirgue()
    }
    
    required init?(coder: NSCoder) {
        super.init(coder: coder)
    }
    //配置
    private func confirgue() {
        //添加圆圈
        addSubview(circleImageView)
        circleImageView.snp.makeConstraints { make in
            make.width.height.equalToSuperview()
            make.center.equalToSuperview()
        }
        circleImageView.isHidden = true
        //添加icon
        addSubview(iconImageView)
        iconImageView.snp.makeConstraints { make in
            make.width.height.equalTo(28*width)
            make.center.equalToSuperview()
        }
    }
}
