CNCertificationView.swift 2.24 KB
//
//  CNCertificationView.swift
//  metaCode
//
//  Created by daojian on 2023/6/12.
//

import Foundation

///身份认证View
class CNCertificationView : UIView{
    ///添加身份点击事件回调
    var addCertificationAction: closeBlock?
    
    lazy var contentView: UIView = {
        let W = self.width-50
        let H = W*1.5
        let contentView = UIView.init(frame: CGRect(x: 25, y: KSreenHeight*0.16, width: W, height: H ))
        contentView.backgroundColor = UIColor.white
        contentView.clipsToBounds = true
        contentView.layer.cornerRadius = 20
        
        return contentView
        
    }()
    
    ///添加身份认证按钮
    lazy var addCerBtn: UIButton = {
        let addCerBtn = UIButton(type: .custom)
        addCerBtn.frame = CGRect(x: 0, y: 0, width: 145, height: 141)
        addCerBtn.centerX = self.contentView.width/2
        addCerBtn.centerY = self.contentView.height/2
        addCerBtn.setImage(UIImage(named: "homePage_addCertification_icon"), for: .normal)
        addCerBtn.addTarget(self, action: #selector(addCerBtnAction), for: .touchUpInside)
        return addCerBtn
    }()
    
    ///添加身份按钮底部标题
    lazy var addCerBtnBottomTitle: UILabel = {
        let addCerBtnBottomTitle = UILabel(frame: CGRect(x: 0, y: self.addCerBtn.bottom - 10, width: 100, height: 22))
        addCerBtnBottomTitle.centerX = self.addCerBtn.centerX
        addCerBtnBottomTitle.textColor = UIColor("#0066FE")
        addCerBtnBottomTitle.textAlignment = .center
        addCerBtnBottomTitle.font = UIFont.systemFont(ofSize: 15, weight: .regular)
        addCerBtnBottomTitle.text = "身份认证"
        return addCerBtnBottomTitle
        
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.initUI()
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func initUI()
    {
        self.addSubview(self.contentView)
        self.contentView.addSubview(self.addCerBtn)
        self.contentView.addSubview(self.addCerBtnBottomTitle)
    }
    
    @objc func addCerBtnAction(){
        
        if(self.addCertificationAction != nil){
            self.addCertificationAction!()
        }
        
    }
}