| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- //
- // KeyboardMenuView.swift
- // AiKeyboard
- //
- // Created by Destiny on 2025/4/28.
- //
- import UIKit
- protocol KeyboardMenuViewDelegate: NSObjectProtocol {
-
- func menuBackBtnClickAction()
-
- func vipBtnClickAction()
-
- func diyBtnClickAction()
-
- func marketBtnClickAction()
- }
- class KeyboardMenuView: UIView {
-
- struct UX {
- static let btnWidth = (KeyboardConst.kb_kScreenW - 36.0) / 2.0
- static let btnHeight = 74.0
- }
-
- weak var delegate: KeyboardMenuViewDelegate?
-
- 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 diyCharacterBtn: UIButton = {
-
- let btn = UIButton(frame: CGRect(x: 0, y: 0, width: UX.btnWidth, height: UX.btnHeight))
- btn.backgroundColor = .white
- btn.layer.cornerRadius = 14
- btn.setTitle("定制人设", for: .normal)
- btn.setTitleColor(.hexStringColor(hexString: "#000000", alpha: 0.8), for: .normal)
- btn.titleLabel?.font = .systemFont(ofSize: 13, weight: .medium)
- btn.titleLabel?.textAlignment = .center
- btn.setImage(UIImage(named: "keyboard_menu_diy"), for: .normal)
- btn.setImageTitleLayout(.imgTop, spacing: 8)
- btn.addTarget(self, action: #selector(diyBtnClickAction), for: .touchUpInside)
- return btn
- }()
-
- lazy var marketBtn: UIButton = {
-
- let btn = UIButton(frame: CGRect(x: 0, y: 0, width: UX.btnWidth, height: UX.btnHeight))
- btn.backgroundColor = .white
- btn.layer.cornerRadius = 14
- btn.setTitle("人设市场", for: .normal)
- btn.setTitleColor(.hexStringColor(hexString: "#000000", alpha: 0.8), for: .normal)
- btn.titleLabel?.font = .systemFont(ofSize: 13, weight: .medium)
- btn.titleLabel?.textAlignment = .center
- btn.setImage(UIImage(named: "keyboard_menu_market"), for: .normal)
- btn.setImageTitleLayout(.imgTop, spacing: 8)
- btn.addTarget(self, action: #selector(marketBtnClickAction), for: .touchUpInside)
- return btn
- }()
-
- lazy var vipBtn: UIButton = {
-
- let btn = UIButton(frame: CGRect(x: 0, y: 0, width: UX.btnWidth, height: UX.btnHeight))
- btn.backgroundColor = .white
- btn.layer.cornerRadius = 14
- btn.setTitle("解锁会员", for: .normal)
- btn.setTitleColor(.hexStringColor(hexString: "#000000", alpha: 0.8), for: .normal)
- btn.titleLabel?.font = .systemFont(ofSize: 13, weight: .medium)
- btn.titleLabel?.textAlignment = .center
- btn.setImage(UIImage(named: "keyboard_menu_vip"), for: .normal)
- btn.setImageTitleLayout(.imgTop, spacing: 8)
- btn.addTarget(self, action: #selector(vipBtnClickAction), for: .touchUpInside)
- return btn
- }()
-
- override init(frame: CGRect) {
- super.init(frame: frame)
- initUI()
- }
-
- required init?(coder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
- }
- extension KeyboardMenuView {
-
- @objc func backBtnClickAction() {
- delegate?.menuBackBtnClickAction()
- }
-
- @objc func vipBtnClickAction() {
- delegate?.vipBtnClickAction()
- }
-
- @objc func marketBtnClickAction() {
- delegate?.marketBtnClickAction()
- }
-
- @objc func diyBtnClickAction() {
- delegate?.diyBtnClickAction()
- }
- }
- extension KeyboardMenuView {
-
- func initUI() {
-
- self.addSubview(backBtn)
- backBtn.snp.makeConstraints { make in
- make.size.equalTo(CGSize(width: 32, height: 32))
- make.left.equalTo(12)
- make.top.equalTo(16)
- }
-
- self.addSubview(diyCharacterBtn)
- diyCharacterBtn.snp.makeConstraints { make in
- make.size.equalTo(CGSize(width: UX.btnWidth, height: UX.btnHeight))
- make.top.equalTo(60)
- make.left.equalTo(12)
- }
-
- self.addSubview(marketBtn)
- marketBtn.snp.makeConstraints { make in
- make.size.equalTo(CGSize(width: UX.btnWidth, height: UX.btnHeight))
- make.top.equalTo(60)
- make.right.equalTo(-12)
- }
-
- self.addSubview(vipBtn)
- vipBtn.snp.makeConstraints { make in
- make.size.equalTo(CGSize(width: UX.btnWidth, height: UX.btnHeight))
- make.top.equalTo(diyCharacterBtn.snp.bottom).offset(12)
- make.left.equalTo(12)
- }
- }
- }
|