NSScrollView - 图案背景 - 如何从左上角开始?

发布于 2024-08-26 06:54:30 字数 305 浏览 5 评论 0原文

要使用图案图像填充 NSScrollview ,我使用 - (void)setBackgroundColor:(NSColor *)aColor 方法,其中 aColor 是使用 + 创建的(NSColor *)colorWithPatternImage:(NSImage *)image 方法。尽管 isFlipped 返回了 NSScrollView 及其内容视图,但模式从左下角开始重复,而我希望它从左上角开始。我怎样才能做到这一点?

To fill NSScrollview with pattern image I use - (void)setBackgroundColor:(NSColor *)aColor method where aColor is created with + (NSColor *)colorWithPatternImage:(NSImage *)image method. Despite of what isFlipped returns for NSScrollView and its content view, pattern start repeat from bottom-left corner while I want it to start from top-left corner. How can I achieve that?

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

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

发布评论

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

评论(2

緦唸λ蓇 2024-09-02 06:54:30

我相信这里的关键可能是 NSScrollView 的 -setBackgroundColor: :

设置内容视图的颜色
aColor 的背景。

NSScrollView 的内容视图是 NSScrollView 内部的一个单独的视图。

因此,您可能需要做的是能够更改 NSScrollView 的内容视图的 isFlipped。

我还没有尝试过这个,所以我不知道你可能会遇到什么问题。

编辑:但是,您的答案似乎可以在这里找到:

CocoaDev: NSScrollView

看看附近文章底部。

I believe the key here may be that -setBackgroundColor: of the NSScrollView:

Sets the color of the content view’s
background to aColor.

The content view of a NSScrollView is a separate view inside of the NSScrollView.

So, what you will probably need to do is be able to change the isFlipped of the content view of the NSScrollView.

I haven't played around with this yet, so I don't know what problems you may run into.

EDIT: However, it appears your answer may be found here:

CocoaDev: NSScrollView

Look near the bottom of the article.

皇甫轩 2024-09-02 06:54:30

您需要使用方法[NSGraphicsContext setPatternPhase:]。 此线程提供了详细信息。这对我有用。

You need to use the method [NSGraphicsContext setPatternPhase:]. This thread provides the details. It worked for me.

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