• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
[SOLVED] How do I pattern an image in a view w/o "scrolling"?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[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


References: 
 >How do I pattern an image in a view w/o "scrolling"? (From: "Alan Smith" <email@hidden>)
 >Re: How do I pattern an image in a view w/o "scrolling"? (From: Michael Watson <email@hidden>)
 >Re: How do I pattern an image in a view w/o "scrolling"? (From: Michael Watson <email@hidden>)
 >Re: How do I pattern an image in a view w/o "scrolling"? (From: Michael Watson <email@hidden>)
 >Re: How do I pattern an image in a view w/o "scrolling"? (From: "Alan Smith" <email@hidden>)
 >Re: How do I pattern an image in a view w/o "scrolling"? (From: Michael Watson <email@hidden>)
 >Re: How do I pattern an image in a view w/o "scrolling"? (From: "Alan Smith" <email@hidden>)
 >Re: How do I pattern an image in a view w/o "scrolling"? (From: glenn andreas <email@hidden>)
 >Re: How do I pattern an image in a view w/o "scrolling"? (From: "Alan Smith" <email@hidden>)
 >Re: Re: How do I pattern an image in a view w/o "scrolling"? (From: "Michael Ash" <email@hidden>)

  • Prev by Date: Re: Re: How do I pattern an image in a view w/o "scrolling"?
  • Next by Date: Re: Mulitple controllers being made
  • Previous by thread: Re: Re: How do I pattern an image in a view w/o "scrolling"?
  • Next by thread: 'inserted' and 'removed' arrays in observeValueForKeyPath's change dictionary always nil
  • Index(es):
    • Date
    • Thread