1
我有一個自定義NSView和兩個NSClipViews。我想爲每個clipview添加一個垂直滾動條。下面的代碼片段顯示了一個NSScroller,但它沒有繪製任何旋鈕或按鈕。互動也是不可能的。 NSScroller是一個小類,所以我不知道我在這裏失去了什麼。如何在自定義NSView中使用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
}