我有一个带有两个 NSClipViews 的自定义 NSView。我想为每个剪辑视图添加一个垂直滚动条。下面的代码片段显示了一个 NSScroller,但它没有绘制任何旋钮或按钮。交互也是不可能的。NSScroller 是一个小类,所以我不确定我在这里缺少什么。
required init?(coder: NSCoder)
{
super.init(coder: coder)
let width = NSScroller.scrollerWidthForControlSize(NSControlSize.RegularControlSize, scrollerStyle: NSScrollerStyle.Overlay)
let scroller = NSScroller(frame: NSRect(x: 10, y: 10, width: width, height: 500))
self.addSubview(scroller)
scroller.doubleValue = 0.5
scroller.knobProportion = 0.1
scroller.needsLayout = true //no effect
scroller.needsDisplay = true //no effect
}