//
//  SHInputAudioButton.swift
//  ShorthandMaster
//
//  Created by 张哲 on 2020/9/24.
//  Copyright © 2020 明津李. All rights reserved.
//

import UIKit

class SHInputAudioButton: UIButton {
    
    // MARK: - property
    /// 背景
    var bgView : UIView!
    /// 左侧图片
    var leftImageView : UIImageView!
    /// 右侧文字
    var rightLabel : UILabel!

    // MARK: - func
    override init(frame: CGRect)
    {
        super.init(frame: frame)
        
        self.layer.masksToBounds = true
        
        self.addSubviews()
        
        self.setUpSubviewsLocation()
    }
    
    required init?(coder: NSCoder)
    {
        fatalError("init(coder:) has not been implemented")
    }
    
    // MARK: - UI
    func addSubviews()
    {
        self.bgView = UIView()
        self.addSubview(self.bgView)
        
        self.leftImageView = UIImageView()
        self.bgView.addSubview(self.leftImageView)
        
        self.rightLabel = UILabel()
        self.rightLabel.font = UIFont(name: SHPingFangMedium, size: 14)
        self.bgView.addSubview(self.rightLabel)
    }
    
    // MARK: 控件位置
    func setUpSubviewsLocation()
    {
        self.bgView.mas_makeConstraints { (make) in
            
            make?.center.equalTo()(self)
            
        }
        
        self.leftImageView.mas_makeConstraints { (make) in
            
            make?.left.equalTo()(self.bgView)
            make?.centerY.equalTo()(self.bgView)
            
        }
        
        self.rightLabel.mas_makeConstraints { (make) in
            
            make?.left.equalTo()(self.leftImageView.mas_right)?.offset()(6)
            make?.centerY.equalTo()(self.bgView)
            make?.right.equalTo()(self.bgView)
            
        }
    }
}
