| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- //
- // KeyboardTipsPopView.swift
- // AiKeyboard
- //
- // Created by Destiny on 2025/5/12.
- //
- import UIKit
- class KeyboardTipsPopView: UIView {
-
- var settingBtnClosure: (() -> ())?
-
- var backBtnClosure: (() -> ())?
-
- lazy var bgView: UIView = {
-
- let view = UIView()
- view.backgroundColor = .hexStringColor(hexString: "#000000").withAlphaComponent(0.8)
- return view
- }()
-
- lazy var mainView: UIView = {
-
- let view = UIView()
- view.layer.cornerRadius = 18
- view.backgroundColor = .white
- return view
- }()
-
- lazy var closeBtn: UIButton = {
-
- let btn = UIButton()
- btn.setImage(UIImage(named: "keyboard_close_btn"), for: .normal)
- btn.addTarget(self, action: #selector(closeBtnClickAction), for: .touchUpInside)
- return btn
- }()
-
- lazy var titleLabel: UILabel = {
-
- let label = UILabel()
- label.text = "开启【追爱小键盘】,并【允许完全访问】"
- label.font = .systemFont(ofSize: 15, weight: .medium)
- label.textColor = .hexStringColor(hexString: "#000000", alpha: 0.8)
- return label
- }()
-
- lazy var mainImageView: UIImageView = {
-
- let imageView = UIImageView()
- imageView.image = UIImage(named: "keyboard_tip_settings")
- return imageView
- }()
-
- lazy var settingBtn: UIButton = {
-
- let btn = UIButton()
- btn.layer.cornerRadius = 17
- btn.setTitle("去设置", for: .normal)
- btn.setTitleColor(.white, for: .normal)
- btn.titleLabel?.font = .systemFont(ofSize: 14, weight: .medium)
-
- if let image = UIImage.gradient([UIColor.hexStringColor(hexString: "#7D46FC"), UIColor.hexStringColor(hexString: "#BC87FF")], size: CGSize(width: 103, height: 34), locations: [0, 1], direction: .horizontal) {
-
- btn.backgroundColor = UIColor(patternImage: image)
- }
-
- btn.addTarget(self, action: #selector(settingBtnClickAction), 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 settingBtnClickAction() {
-
- settingBtnClosure?()
- }
-
- @objc func closeBtnClickAction() {
-
- self.removeFromSuperview()
- backBtnClosure?()
- }
- }
- extension KeyboardTipsPopView {
-
- func initUI() {
-
- self.addSubview(bgView)
- bgView.snp.makeConstraints { make in
- make.edges.equalToSuperview()
- }
-
- self.addSubview(mainView)
- mainView.snp.makeConstraints { make in
- make.size.equalTo(CGSize(width: 296, height: 209))
- make.centerX.equalToSuperview()
- make.top.equalTo(14)
- }
-
- self.mainView.addSubview(closeBtn)
- closeBtn.snp.makeConstraints { make in
- make.size.equalTo(CGSize(width: 24, height: 24))
- make.right.equalTo(-13)
- make.top.equalTo(12)
- }
-
- self.mainView.addSubview(titleLabel)
- titleLabel.snp.makeConstraints { make in
- make.centerX.equalToSuperview()
- make.top.equalTo(38)
- }
-
- self.mainView.addSubview(mainImageView)
- mainImageView.snp.makeConstraints { make in
- make.size.equalTo(CGSize(width: 254, height: 77))
- make.top.equalTo(titleLabel.snp.bottom).offset(14)
- make.centerX.equalToSuperview()
- }
-
- self.mainView.addSubview(settingBtn)
- settingBtn.snp.makeConstraints { make in
- make.size.equalTo(CGSize(width: 103, height: 34))
- make.top.equalTo(mainImageView.snp.bottom).offset(14)
- make.centerX.equalToSuperview()
- }
- }
- }
|