Search code examples
objective-cxcodecocoaquartz-graphicsnsview

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);

Solution

  • 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