AccountIconView.swift 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //
  2. // AccountIconView.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by User-Tangchao on 2024/10/28.
  6. //
  7. import Cocoa
  8. class AccountIconView: NSView {
  9. private lazy var iconIv_: NSImageView = {
  10. let view = NSImageView()
  11. view.image = NSImage(named: "KMImageNameAccountLogo")
  12. return view
  13. }()
  14. private lazy var label_: NSTextField = {
  15. let view = NSTextField(labelWithString: NSLocalizedString("AnyRecover", comment: ""))
  16. view.textColor = KMAppearance.themeColor()
  17. return view
  18. }()
  19. private lazy var iv_: NSImageView = {
  20. let view = NSImageView()
  21. view.image = NSImage(named: "KMImageNameAccountLogo2")
  22. return view
  23. }()
  24. override func draw(_ dirtyRect: NSRect) {
  25. super.draw(dirtyRect)
  26. // Drawing code here.
  27. }
  28. convenience init() {
  29. self.init(frame: .init(x: 0, y: 0, width: 120, height: 40))
  30. self.initSubviews()
  31. self.initDefaultValue()
  32. }
  33. override func awakeFromNib() {
  34. super.awakeFromNib()
  35. self.initSubviews()
  36. self.initDefaultValue()
  37. }
  38. func initSubviews() {
  39. addSubview(iconIv_)
  40. addSubview(label_)
  41. addSubview(iv_)
  42. iconIv_.km_add_left_constraint()
  43. iconIv_.km_add_size_constraint(size: .init(width: 40, height: 40))
  44. iconIv_.km_add_centerY_constraint()
  45. label_.km_add_leading_constraint(equalTo: iconIv_, attribute: .trailing, constant: 10)
  46. label_.km_add_top_constraint()
  47. iv_.km_add_leading_constraint(equalTo: iconIv_, attribute: .trailing, constant: 10)
  48. iv_.km_add_size_constraint(size: .init(width: 71, height: 17))
  49. iv_.km_add_bottom_constraint()
  50. }
  51. func initDefaultValue() {}
  52. }