60 lines
1.2 KiB
Swift
60 lines
1.2 KiB
Swift
![]() |
//
|
||
|
// AuthItmeButton.swift
|
||
|
// yinmeng-ios
|
||
|
//
|
||
|
// Created by MaiMang on 2024/2/28.
|
||
|
//
|
||
|
|
||
|
import UIKit
|
||
|
|
||
|
class AuthItmeButton: UIControl {
|
||
|
var title:String? {
|
||
|
didSet {
|
||
|
titleLb.text = title
|
||
|
}
|
||
|
}
|
||
|
|
||
|
var imageName:String? {
|
||
|
didSet {
|
||
|
guard let imageName = imageName else { return}
|
||
|
imgView.image = UIImage(named: imageName)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
override init(frame: CGRect) {
|
||
|
super.init(frame: frame)
|
||
|
addSubview(imgView)
|
||
|
addSubview(titleLb)
|
||
|
imgView.snp.makeConstraints { make in
|
||
|
make.size.equalTo(CGSize(width: 47, height: 47))
|
||
|
make.top.centerX.equalTo(self)
|
||
|
}
|
||
|
|
||
|
titleLb.snp.makeConstraints { make in
|
||
|
make.centerX.equalTo(self)
|
||
|
make.top.equalTo(imgView.snp.bottom).offset(6)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
required init?(coder: NSCoder) {
|
||
|
fatalError("init(coder:) has not been implemented")
|
||
|
}
|
||
|
|
||
|
private lazy var imgView: UIImageView = {
|
||
|
let imageView = UIImageView()
|
||
|
imageView.isUserInteractionEnabled = false
|
||
|
imageView.layer.masksToBounds = true
|
||
|
imageView.contentMode = .scaleAspectFill
|
||
|
return imageView
|
||
|
}()
|
||
|
|
||
|
private lazy var titleLb: UILabel = {
|
||
|
let label = UILabel()
|
||
|
label.textColor = .white
|
||
|
label.font = UIFont.systemFont(ofSize: 12)
|
||
|
return label
|
||
|
}()
|
||
|
|
||
|
|
||
|
}
|