84 lines
2.1 KiB
Swift
84 lines
2.1 KiB
Swift
//
|
|
// FAMeCoinsView.swift
|
|
// Fableon
|
|
//
|
|
// Created by 湖北秦九 on 2025/10/22.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
class FAMeCoinsView: UIControl {
|
|
|
|
var title: String? {
|
|
didSet {
|
|
titleLabel.text = title
|
|
}
|
|
}
|
|
|
|
var count: Int = 0 {
|
|
didSet {
|
|
coinLabel.text = "\(count)"
|
|
}
|
|
}
|
|
|
|
private lazy var coinImageView: UIImageView = {
|
|
let imageView = UIImageView(image: UIImage(named: "coins_icon_01"))
|
|
imageView.setContentHuggingPriority(.required, for: .horizontal)
|
|
imageView.setContentCompressionResistancePriority(.required, for: .horizontal)
|
|
return imageView
|
|
}()
|
|
|
|
private lazy var titleLabel: UILabel = {
|
|
let label = UILabel()
|
|
label.font = .font(ofSize: 10, weight: .bold)
|
|
label.textColor = .F_7_F_497
|
|
return label
|
|
}()
|
|
|
|
private lazy var coinLabel: UILabel = {
|
|
let label = UILabel()
|
|
label.font = .font(ofSize: 14, weight: .bold)
|
|
label.textColor = .FFFFFF
|
|
return label
|
|
}()
|
|
|
|
override init(frame: CGRect) {
|
|
super.init(frame: frame)
|
|
|
|
fa_setupLayout()
|
|
}
|
|
|
|
required init?(coder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
|
|
}
|
|
|
|
extension FAMeCoinsView {
|
|
|
|
private func fa_setupLayout() {
|
|
addSubview(coinImageView)
|
|
addSubview(titleLabel)
|
|
addSubview(coinLabel)
|
|
|
|
coinImageView.snp.makeConstraints { make in
|
|
make.left.equalToSuperview()
|
|
make.centerY.equalToSuperview()
|
|
make.top.equalToSuperview()
|
|
}
|
|
|
|
titleLabel.snp.makeConstraints { make in
|
|
make.top.equalToSuperview().offset(-2)
|
|
make.left.equalTo(coinImageView.snp.right).offset(10)
|
|
make.right.lessThanOrEqualToSuperview()
|
|
}
|
|
|
|
coinLabel.snp.makeConstraints { make in
|
|
make.left.equalTo(titleLabel)
|
|
make.right.lessThanOrEqualToSuperview()
|
|
make.bottom.equalToSuperview().offset(0)
|
|
}
|
|
}
|
|
|
|
}
|