KeyboardLoginTipView.swift 3.0 KB

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