2024-03-01 16:54:46 +08:00
|
|
|
//
|
|
|
|
// HomeVoiceRecordBtnView.swift
|
|
|
|
// yinmeng-ios
|
|
|
|
//
|
2024-03-05 14:04:09 +08:00
|
|
|
// Created by yinmeng on 2024/3/1.
|
2024-03-01 16:54:46 +08:00
|
|
|
//
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
|
|
|
|
class HomeVoiceRecordBtnView: UIView {
|
|
|
|
|
|
|
|
override init(frame: CGRect) {
|
|
|
|
super.init(frame: frame)
|
|
|
|
setUILayout()
|
|
|
|
|
|
|
|
}
|
|
|
|
func setUILayout(){
|
|
|
|
backgroundColor = ThemeColor(hexStr: "#9552FF")
|
|
|
|
layer.cornerRadius = 24
|
|
|
|
addSubview(micImageView)
|
|
|
|
addSubview(pointView)
|
|
|
|
addSubview(recordTextView)
|
|
|
|
micImageView.snp.makeConstraints { make in
|
|
|
|
make.width.equalTo(22)
|
|
|
|
make.height.equalTo(28)
|
|
|
|
make.centerX.equalTo(self)
|
|
|
|
make.top.equalTo(12)
|
|
|
|
}
|
|
|
|
pointView.snp.makeConstraints { make in
|
|
|
|
make.width.height.equalTo(6)
|
|
|
|
make.top.equalTo(34)
|
|
|
|
make.left.equalTo(40)
|
|
|
|
}
|
|
|
|
recordTextView.snp.makeConstraints { make in
|
|
|
|
make.top.equalTo(42)
|
|
|
|
make.height.equalTo(18)
|
|
|
|
make.left.right.equalTo(self)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
required init?(coder: NSCoder) {
|
|
|
|
fatalError("init(coder:) has not been implemented")
|
|
|
|
}
|
|
|
|
var micImageView:UIImageView = {
|
|
|
|
let _micImageView = UIImageView()
|
|
|
|
_micImageView.image = UIImage(named: "yin_home_voiec_record_btn_mic")
|
|
|
|
|
|
|
|
return _micImageView
|
|
|
|
}()
|
|
|
|
var recordTextView:UILabel = {
|
|
|
|
let _recordTextView = UILabel()
|
|
|
|
_recordTextView.text = "长按录制"
|
|
|
|
_recordTextView.font = UIFont.systemFont(ofSize: 12, weight: .regular)
|
|
|
|
_recordTextView.textColor = .white
|
|
|
|
_recordTextView.textAlignment = .center
|
|
|
|
return _recordTextView
|
|
|
|
}()
|
|
|
|
var pointView:UIView = {
|
|
|
|
let _pointView = UILabel()
|
|
|
|
_pointView.backgroundColor = ThemeColor(hexStr: "#43F4FF")
|
|
|
|
_pointView.layer.cornerRadius = 3
|
|
|
|
_pointView.layer.masksToBounds = true
|
|
|
|
return _pointView
|
|
|
|
}()
|
|
|
|
var type:Int = 0 {
|
|
|
|
didSet{
|
|
|
|
pointView.isHidden = false
|
|
|
|
if type == 0{
|
|
|
|
micImageView.image = UIImage(named: "yin_home_voiec_record_btn_mic")
|
|
|
|
recordTextView.text = "长按录制"
|
|
|
|
pointView.backgroundColor = ThemeColor(hexStr: "#43F4FF")
|
|
|
|
}else if type == 1{
|
|
|
|
micImageView.image = UIImage(named: "yin_home_voiec_record_btn_mic")
|
|
|
|
pointView.backgroundColor = ThemeColor(hexStr: "#FF43B1")
|
|
|
|
}else{
|
|
|
|
pointView.isHidden = true
|
|
|
|
micImageView.image = UIImage(named: "yin_home_voiec_record_btn_no_mic")
|
|
|
|
recordTextView.text = "录制完成"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|