【Swift Mac开发】修改NSTableView的headerView的背景颜色
作者:互联网
// // BMTableViewHeaderCell.swift // BullMan // // Created by Apple on 2021/5/14. // import Foundation class BMTableViewHeaderCell: NSTableHeaderCell { override func draw(withFrame cellFrame: NSRect, in controlView: NSView) { super.draw(withFrame: cellFrame, in: controlView) self.alignment = .center controlView.layer?.backgroundColor = NSColor.white.cgColor } }
使用:
let secondCol = NSTableColumn(identifier: NSUserInterfaceItemIdentifier(rawValue: "secondCol")) secondCol.width = 90 let secondHeaderCell = BMTableViewHeaderCell() secondHeaderCell.alignment = .center secondHeaderCell.stringValue = "合约代码" secondCol.headerCell = secondHeaderCell
标签:draw,headerView,secondHeaderCell,controlView,Mac,secondCol,BMTableViewHeaderCell 来源: https://www.cnblogs.com/xjf125/p/14768240.html