[英]How to change the color of NSSplitView's divider on nib?
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. 我想在我的Cocoa应用程序中更改
NSSplitView
的dividerColor
的颜色,但是当我输入以下代码时,错误Cannot assign to the result of this expression
。
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. 我认为这是因为
.dividerColor
是一个只读属性,因此如果从nib实例化它,则无法覆盖代码中的颜色。
However, I cannot find any such preferences to change the color in Xcode's Inspector on the NSSplitView
. 但是,我找不到任何这样的首选项来更改
NSSplitView
上Xcode的Inspector中的NSSplitView
。 So how can I change the color of the divider? 那么我怎样才能改变分频器的颜色呢?
Note that I don't use NSSplitViewController
; 请注意,我不使用
NSSplitViewController
; I use NSSplitView
on top of the NSViewController
. 我在
NSSplitView
之上使用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: 如果您乐于坚持使用Thin Divider样式,可以使用NSSplitView的子类更改splitview的分隔符的
NSSplitView
,并覆盖dividerColor
属性:
class MySplitView: NSSplitView {
override var dividerColor: NSColor {
return NSColor.redColor()
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.