| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- //
- // KeyboardLoginTipView.swift
- // AiKeyboard
- //
- // Created by Destiny on 2025/4/25.
- //
- import UIKit
- class KeyboardLoginTipView: UIView {
-
- var loginBtnClosure: (() -> ())?
-
- var backBtnClosure: (() -> ())?
-
- lazy var bgImageView: UIImageView = {
-
- let imageView = UIImageView()
- imageView.image = UIImage(named: "keyboard_bg")
- return imageView
- }()
-
- lazy var backBtn: UIButton = {
-
- let btn = UIButton()
- btn.setImage(UIImage(named: "keyboard_back_btn"), for: .normal)
- btn.layer.shadowOffset = CGSize(width: 0, height: 0)
- btn.layer.shadowColor = UIColor.hexStringColor(hexString: "#000000", alpha: 0.12).cgColor
- btn.layer.shadowRadius = 6.1
- btn.addTarget(self, action: #selector(backBtnClickAction), for: .touchUpInside)
- return btn
- }()
-
- lazy var logoIcon: UIImageView = {
-
- let icon = UIImageView()
- icon.image = UIImage(named: "keyboard_logo")
- return icon
- }()
-
- lazy var loginLabel: UILabel = {
-
- let label = UILabel()
- label.text = "请登录后使用"
- label.font = .systemFont(ofSize: 22, weight: .medium)
- label.textColor = .hexStringColor(hexString: "#000000", alpha: 0.8)
- return label
- }()
-
- lazy var loginBtn: UIButton = {
-
- let btn = UIButton()
- btn.layer.cornerRadius = 24
- btn.setTitle("去登录", for: .normal)
- btn.setTitleColor(.white, for: .normal)
-
- if let image = UIImage.gradient([UIColor.hexStringColor(hexString: "#7D46FC"), UIColor.hexStringColor(hexString: "#BC87FF")], size: CGSize(width: 300, height: 48), locations: [0, 1], direction: .horizontal) {
-
- btn.backgroundColor = UIColor(patternImage: image)
- }
-
- btn.addTarget(self, action: #selector(loginBtnClickAction), for: .touchUpInside)
- return btn
- }()
-
- override init(frame: CGRect) {
- super.init(frame: frame)
- initUI()
- }
-
- required init?(coder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
-
- @objc func loginBtnClickAction() {
-
- loginBtnClosure?()
- }
-
- @objc func backBtnClickAction() {
-
- backBtnClosure?()
- }
- }
- extension KeyboardLoginTipView {
-
- func initUI() {
-
- self.addSubview(bgImageView)
- bgImageView.snp.makeConstraints { make in
- make.edges.equalToSuperview()
- }
-
- self.addSubview(backBtn)
- backBtn.snp.makeConstraints { make in
- make.size.equalTo(CGSize(width: 32, height: 32))
- make.left.equalTo(12)
- make.top.equalTo(14)
- }
-
- self.addSubview(logoIcon)
- logoIcon.snp.makeConstraints { make in
- make.size.equalTo(CGSize(width: 83, height: 83))
- make.centerX.equalToSuperview()
- make.top.equalTo(70)
- }
-
- self.addSubview(loginLabel)
- loginLabel.snp.makeConstraints { make in
- make.centerX.equalToSuperview()
- make.top.equalTo(logoIcon.snp.bottom).offset(14)
- }
-
- self.addSubview(loginBtn)
- loginBtn.snp.makeConstraints { make in
- make.size.equalTo(CGSize(width: 300, height: 48))
- make.top.equalTo(loginLabel.snp.bottom).offset(29)
- make.centerX.equalToSuperview()
- }
- }
- }
|