学习过
iOS开发的同学对于如何设置一个控件的backgroundColor是在熟悉不过的了, 但是相对于macOS开发中,NSView的属性中并没有发现color相关的属性, 那么如何设置呢?
- macOS中, 将
NSView的backgroundColor放到了layer中:
@IBOutlet var dragcontentView: NSView!
self.dragcontentView.layer?.backgroundColor = NSColor.clear.cgColor;
B&R后发现并没有改变颜色, 因为我们未设置时候允许NSView的wantsLayer属性:
@IBOutlet var dragcontentView: NSView!
self.dragcontentView.wantsLayer = true;
self.dragcontentView.layer?.backgroundColor = NSColor.clear.cgColor;
搞定!





近期评论