1

I'm experiencing a weird problem (Bug?): Say I have a WebView, which will scroll vertically.

I now want to shrink the mainFrame's vertical scroller a little bit, so that its height is smaller than the NSScrollView itself.

enter image description here

The reason for this is that I want to pin two views (on top and on bottom edge) above the webview.

I did that easily in the frameLoad delegate method by altering the verticalScroller's frame (altering origin and height).

It works, but:

However once I set the webView and it's parent NSView to be layer-backed, it stops working, the scroller resets itself to the default position and height.

Now I don't know if this is a bug or not. Is there any other way I could try to 'inset' the scroller?

4

1 回答 1

2

您是否尝试过继承 NSScroller,将其设置为 NSScrollView 的垂直滚动条并覆盖

-(void) setFrameOrigin:(NSPoint)origin;
-(void) setFrameSize:(NSSize)size;

我假设使 NSView 层支持会导致 frameSize 再次设置(NSScrollView 似乎对此进行了相当多的控制,因为当您创建自定义滚动条时,没有“干净”的方式将 NSScroller 设置为水平或垂直其他比调用 - initWithFrame : with

  1. height > width 自动设置为垂直
  2. width > height 自动设置为水平

我的另一个建议是,如果您希望 NSScroller 不完全反映其父 NSScrollView 的大小,您最好将 NSView 作为 webview 的内容视图。NSView 有 3 个子视图。顶部和底部固定了两个视图,中间有一个 NSScrollView。在这种情况下不需要自定义 NSScroller。

于 2013-11-03T21:45:47.997 回答