Antwan van Houdt
Antwan van Houdt

Reputation: 6991

NSImage + NSColor + pattern

Trying to draw a background that repeats on the x-axes. However the image is misplaced and when I resize the window the view sits in the pattern will start "moving".

What am I doing wrong? Currently doing the following:

[[NSColor colorWithPatternImage:[NSImage imageNamed:@"inactiveTabFill"]] set];
NSRectFill(dirtyRect);

Upvotes: 1

Views: 1370

Answers (2)

Joe Strout
Joe Strout

Reputation: 2741

Sorry for chiming in (very) late, but wouldn't it be much simpler and more efficient to adjust the pattern phase, as described here?

Upvotes: 2

Ernesto
Ernesto

Reputation: 510

I've recently found this problem myself. The solution was to create an image with the size of the view, and draw the pattern to the image. Then, draw the image to the view.

I found the solution in Christian Kienle's Blog

Upvotes: 3

Related Questions