//
//  MPCustomTabBarItem.swift
//  MusicPlayer
//
//  Created by Mr.Zhou on 2024/3/27.
//

import UIKit
///自定义tabBarItem
class MPCustomTabBarItem: UIView {
    //icon图片
    fileprivate lazy var iconImageView:UIImageView = {
        let imageView:UIImageView = .init()
        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")
            }else{
                //未选中
                iconImageView.image = UIImage(named: title)
            }
        }
    }
    override init(frame: CGRect) {
        super.init(frame: frame)
        setUpLayout()
    }
    
    required init?(coder: NSCoder) {
        super.init(coder: coder)
        setUpLayout()
    }
    //MARK: - 布局实现
    fileprivate func setUpLayout() {
        backgroundColor = .clear
        addSubview(iconImageView)
        iconImageView.snp.makeConstraints { make in
            make.width.height.equalToSuperview()
            make.center.equalToSuperview()
        }
    }
}
