How do I override layout of NSTableHeaderView?

前端 未结 4 1823
说谎
说谎 2021-01-06 06:30

I am trying to produce a custom header for my NSTableView. I would like to change the font of the header text and remove the borders and vertical separators.

My curr

4条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-06 07:04

    The above answers works also directly you can use in viewDidLoad

    override func viewDidLoad() {
            super.viewDidLoad()   
            tableView.tableColumns.forEach { (column) in
                    column.headerCell.backgroundColor = NSColor.white
                    column.headerCell.drawsBackground = true
                    column.headerCell.isBordered = false
                    column.headerCell.attributedStringValue = NSAttributedString(string: column.title, attributes: [NSAttributedString.Key.font: NSFont.systemFont(ofSize: 13)])
                  }
    }
    

提交回复
热议问题