[SOLVED] How do I pattern an image in a view w/o "scrolling"?
[SOLVED] How do I pattern an image in a view w/o "scrolling"?
- Subject: [SOLVED] How do I pattern an image in a view w/o "scrolling"?
- From: "Alan Smith" <email@hidden>
- Date: Fri, 28 Jul 2006 13:40:42 -0400
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."
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden