NSScrollView 滚动位置

发布于 2024-10-05 12:48:54 字数 219 浏览 0 评论 0原文

我目前在 NSScrollView 中有一个 NSView。 NSView 很大,我需要滚动来管理里面的对象。

我想在 NSView 的中心绘制一个静态矩形而不滚动。 我想在NSView的drawRect方法中获取滚动点(NSClipPoint?),以便我可以在drawRect的最后一步绘制矩形,使其位于顶部。

我浏览了文档,只能找到设置滚动点的方法,但没有找到它。 我怎样才能得到这一点?

I currently have a NSView in a NSScrollView.
The NSView is large and I need to scroll to manage the object inside.

I want to draw a static rectangle in the center of the NSView without scrolling.
I want to get the scrolling point (the NSClipPoint?) in the drawRect method of the NSView so that I can draw the rectangle at the last step of drawRect to make it on top.

I have looked through the doc and could only find methods to set the scroll point, not getting it.
How can I get that point?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梨涡 2024-10-12 12:48:54

答案是[[myScrollView contentView] documentVisibleRect]

The answer is [[myScrollView contentView] documentVisibleRect]

行雁书 2024-10-12 12:48:54

我从未尝试过这个,所以我不知道它是否真的有效(而且我距离 Mac 大约有 8 个小时的路程,所以我无法尝试)。但是你可以子类化你的 NSScrollView 正在使用的 NSClipView 并在 NSClipView 的 drawRect: 中绘制矩形吗?如果这不起作用,直接用 NSScrollView 尝试同样的事情怎么样?

如果这不起作用,呃...报告回来,我会删除这个答案,以免误导来自谷歌的任何人。 :)

I've never tried this, so I don't know if it will actually work or not (and I'm about 8 hours away from my Mac, so I can't give it a shot). But can you subclass the NSClipView that your NSScrollView is using and draw the rectangle in NSClipView's drawRect:? If that doesn't work, what about trying the same thing with the NSScrollView directly?

And if that doesn't work, er...report back and I'll remove this answer so as not to mislead anyone coming from Google. :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文