AccountRightListView.swift 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //
  2. // AccountRightListView.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by User-Tangchao on 2024/10/28.
  6. //
  7. import Cocoa
  8. class AccountRightListView: NSView , NibLoadable{
  9. @IBOutlet weak var scrollView: NSScrollView!
  10. @IBOutlet weak var tableView: NSTableView!
  11. var rightDatas: [String] = [] {
  12. didSet {
  13. DispatchQueue.main.async {
  14. self.tableView.reloadData()
  15. }
  16. }
  17. }
  18. override func draw(_ dirtyRect: NSRect) {
  19. super.draw(dirtyRect)
  20. // Drawing code here.
  21. }
  22. override func awakeFromNib() {
  23. super.awakeFromNib()
  24. // wantsLayer = true
  25. // layer?.backgroundColor = NSColor.clear.cgColor
  26. // scrollView.borderType = .noBorder
  27. // scrollView.drawsBackground = false
  28. // scrollView.backgroundColor = .orange
  29. // scrollView.wantsLayer = true
  30. // scrollView.layer?.backgroundColor = NSColor.purple.cgColor
  31. tableView.backgroundColor = .clear
  32. tableView.delegate = self
  33. tableView.dataSource = self
  34. }
  35. }
  36. extension AccountRightListView: NSTableViewDelegate, NSTableViewDataSource {
  37. func numberOfRows(in tableView: NSTableView) -> Int {
  38. return self.rightDatas.count
  39. }
  40. func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
  41. var view = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "Cell"), owner: nil) as? AccountRightListCellView
  42. if view == nil {
  43. view = AccountRightListCellView()
  44. view?.iconIv.image = NSImage(named: "KMImageNameAccountRightListIcon")
  45. view?.label.stringValue = self.rightDatas[row]
  46. view?.label.textColor = KMAppearance.accountPurpleColor()
  47. }
  48. return view
  49. }
  50. func tableView(_ tableView: NSTableView, heightOfRow row: Int) -> CGFloat {
  51. return 34
  52. }
  53. }