KeyboardLoginTipView.swift 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. //
  2. // KeyboardLoginTipView.swift
  3. // AiKeyboard
  4. //
  5. // Created by Destiny on 2025/4/25.
  6. //
  7. import UIKit
  8. class KeyboardLoginTipView: UIView {
  9. var loginBtnClosure: (() -> ())?
  10. var backBtnClosure: (() -> ())?
  11. lazy var bgImageView: UIImageView = {
  12. let imageView = UIImageView()
  13. imageView.image = UIImage(named: "keyboard_bg")
  14. return imageView
  15. }()
  16. lazy var backBtn: UIButton = {
  17. let btn = UIButton()
  18. btn.setImage(UIImage(named: "keyboard_back_btn"), for: .normal)
  19. btn.layer.shadowOffset = CGSize(width: 0, height: 0)
  20. btn.layer.shadowColor = UIColor.hexStringColor(hexString: "#000000", alpha: 0.12).cgColor
  21. btn.layer.shadowRadius = 6.1
  22. btn.addTarget(self, action: #selector(backBtnClickAction), for: .touchUpInside)
  23. return btn
  24. }()
  25. lazy var logoIcon: UIImageView = {
  26. let icon = UIImageView()
  27. icon.image = UIImage(named: "keyboard_logo")
  28. return icon
  29. }()
  30. lazy var loginLabel: UILabel = {
  31. let label = UILabel()
  32. label.text = "请登录后使用"
  33. label.font = .systemFont(ofSize: 22, weight: .medium)
  34. label.textColor = .hexStringColor(hexString: "#000000", alpha: 0.8)
  35. return label
  36. }()
  37. lazy var loginBtn: UIButton = {
  38. let btn = UIButton()
  39. btn.layer.cornerRadius = 24
  40. btn.setTitle("去登录", for: .normal)
  41. btn.setTitleColor(.white, for: .normal)
  42. if let image = UIImage.gradient([UIColor.hexStringColor(hexString: "#7D46FC"), UIColor.hexStringColor(hexString: "#BC87FF")], size: CGSize(width: 300, height: 48), locations: [0, 1], direction: .horizontal) {
  43. btn.backgroundColor = UIColor(patternImage: image)
  44. }
  45. btn.addTarget(self, action: #selector(loginBtnClickAction), for: .touchUpInside)
  46. return btn
  47. }()
  48. override init(frame: CGRect) {
  49. super.init(frame: frame)
  50. initUI()
  51. }
  52. required init?(coder: NSCoder) {
  53. fatalError("init(coder:) has not been implemented")
  54. }
  55. @objc func loginBtnClickAction() {
  56. loginBtnClosure?()
  57. }
  58. @objc func backBtnClickAction() {
  59. backBtnClosure?()
  60. }
  61. }
  62. extension KeyboardLoginTipView {
  63. func initUI() {
  64. self.addSubview(bgImageView)
  65. bgImageView.snp.makeConstraints { make in
  66. make.edges.equalToSuperview()
  67. }
  68. self.addSubview(backBtn)
  69. backBtn.snp.makeConstraints { make in
  70. make.size.equalTo(CGSize(width: 32, height: 32))
  71. make.left.equalTo(12)
  72. make.top.equalTo(14)
  73. }
  74. self.addSubview(logoIcon)
  75. logoIcon.snp.makeConstraints { make in
  76. make.size.equalTo(CGSize(width: 83, height: 83))
  77. make.centerX.equalToSuperview()
  78. make.top.equalTo(70)
  79. }
  80. self.addSubview(loginLabel)
  81. loginLabel.snp.makeConstraints { make in
  82. make.centerX.equalToSuperview()
  83. make.top.equalTo(logoIcon.snp.bottom).offset(14)
  84. }
  85. self.addSubview(loginBtn)
  86. loginBtn.snp.makeConstraints { make in
  87. make.size.equalTo(CGSize(width: 300, height: 48))
  88. make.top.equalTo(loginLabel.snp.bottom).offset(29)
  89. make.centerX.equalToSuperview()
  90. }
  91. }
  92. }