When the outline view is restoring the saved expanded items, this method is called for each expanded item, to translate the archived object to an outline view item.
When the outline view is saving the expanded items, this method is called for each expanded item, to translate the outline view item to an archived object.
class CategoryTableRowView: NSTableRowView {
override func drawSelection(in dirtyRect: NSRect) {
if selectionHighlightStyle != .none {
let selectionRect = bounds.insetBy(dx: 2.5, dy: 2.5)
NSColor(calibratedRed: 61.0/255.0, green: 159.0/255.0, blue: 219.0/255.0, alpha: 1.0).setStroke()
NSColor(calibratedWhite: 1.0, alpha: 1.0).setFill()
let selectionPath = NSBezierPath(roundedRect: selectionRect, xRadius: 25, yRadius: 25)
selectionPath.fill()
selectionPath.stroke()
}
}
}
func tableView(_ tableView: NSTableView, rowViewForRow row: Int) -> NSTableRowView? {
return CategoryTableRowView()
}
override func viewDidLoad() {
super.viewDidLoad()
self.outlineView.selectionHighlightStyle = .regular
}
override the backgroundStyle property and set the desired color for the text.
class CategoryCellView: NSTableCellView {
var oldColor : NSColor? = nil
var oldFont : NSFont? = nil
override var backgroundStyle: NSView.BackgroundStyle {
willSet{
if newValue == .emphasized {
textField?.font = NSFont.systemFont(ofSize: 14)
textField?.textColor = NSColor.textColor
} else {
if oldColor == nil {
oldColor = textField?.textColor!
oldFont = textField?.font
}
textField?.textColor = oldColor
textField?.font = oldFont
}
super.backgroundStyle = newValue
}
}
}
Normal
Select light
Select dark