I want to change the color of NSSplitView
's dividerColor
in my Cocoa app, but when I typed in the following code, the error Cannot assign to the result of this expression
occurred.
splitView.dividerColor = NSColor.redColor()
I think this is because .dividerColor
is a read-only property and thus you cannot overwrite the color from within code if you instantiate it from nib.
However, I cannot find any such preferences to change the color in Xcode's Inspector on the NSSplitView
. So how can I change the color of the divider?
Note that I don't use NSSplitViewController
; I use NSSplitView
on top of the NSViewController
.
If you're happy to stick to using the Thin Divider style, you can change the color of the splitview's divider by using a subclass of NSSplitView
, and overriding the dividerColor
property:
class MySplitView: NSSplitView {
override var dividerColor: NSColor {
return NSColor.redColor()
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With