开发者

NSScrollView - pattern background - how to start from top-left corner?

开发者 https://www.devze.com 2022-12-23 19:30 出处:网络
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 wh

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 a开发者_如何学Cchieve that?


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消