Skip navigation.
 
ml[SOLVED] How do I pattern an image in a view w/o "scrolling"?
FROM : Alan Smith
DATE : Fri Jul 28 19:40:42 2006

YYYEEESS!! It works!! Thank you thank you thank you!!

I'm really sorry I didn't post the code in my first post but, I got no
compiler errors and it ran without crashing. I didn't see anything
wrong with it and knowing nothing about GraphicContext  I didn't
realize it was the wrong context.

For future reference:

- (void)drawRect:(NSRect)rect
{
    NSImage *pattern = [[NSImage alloc] initWithContentsOfFile: (path
to the tile image file)];
    NSPoint origin = [self visibleRect].origin;
    [[NSGraphicsContext currentContext]
setPatternPhase:NSMakePoint(origin.x, origin.y)];
    [[NSColor colorWithPatternImage: pattern] set];
    [NSBezierPath fillRect: [self bounds]];

    [pattern release];
}

That will fill a NSView subclass with 'pattern,' an NSImage containing
a picture to be tiled. :-)

Thank you everyone!!! This thread should go down in history: "When
should you post your code?" would be the title. The answer will be:
ALWAYS!!

I'll be sure to remember that.

Thanks again, Alan

--
// Quotes from yours truly -------------------------
"You don't forget, you just don't remember."
"Maturity resides in the mind."
"Silence is the Universe's greatest gift."
"Don't waste your life doing things others have already done."