123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- //
- // AccountRightListView.swift
- // PDF Reader Pro
- //
- // Created by User-Tangchao on 2024/10/28.
- //
- import Cocoa
- class AccountRightListView: NSView , NibLoadable{
- @IBOutlet weak var scrollView: NSScrollView!
- @IBOutlet weak var tableView: NSTableView!
-
- var rightDatas: [String] = [] {
- didSet {
- DispatchQueue.main.async {
- self.tableView.reloadData()
- }
- }
- }
-
- override func draw(_ dirtyRect: NSRect) {
- super.draw(dirtyRect)
- // Drawing code here.
- }
-
- override func awakeFromNib() {
- super.awakeFromNib()
-
- // wantsLayer = true
- // layer?.backgroundColor = NSColor.clear.cgColor
-
- // scrollView.borderType = .noBorder
- // scrollView.drawsBackground = false
- // scrollView.backgroundColor = .orange
- // scrollView.wantsLayer = true
- // scrollView.layer?.backgroundColor = NSColor.purple.cgColor
-
- tableView.backgroundColor = .clear
- tableView.delegate = self
- tableView.dataSource = self
- }
- }
- extension AccountRightListView: NSTableViewDelegate, NSTableViewDataSource {
- func numberOfRows(in tableView: NSTableView) -> Int {
- return self.rightDatas.count
- }
-
- func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
- var view = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "Cell"), owner: nil) as? AccountRightListCellView
- if view == nil {
- view = AccountRightListCellView()
- view?.iconIv.image = NSImage(named: "KMImageNameAccountRightListIcon")
- view?.label.stringValue = self.rightDatas[row]
- view?.label.textColor = KMAppearance.accountPurpleColor()
- }
-
- return view
- }
-
- func tableView(_ tableView: NSTableView, heightOfRow row: Int) -> CGFloat {
- return 34
- }
- }
|