Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Odd redraw issue



On Thu, 13 Jul 2006 22:58:19 +1000, Gideon King <email@hidden> said:
>Hi, I have a problem in that drawing a pattern image in a view which
>is in a scroll view makes a mess when the view is scrolled. I created
>a test project and made a custom view, made it a subview of a
>scrollview, and put an image in my project and the only code I had in
>the custom view was the following:
>
>- (void)drawRect:(NSRect)rect {
> [[NSColor whiteColor] set];
> NSRectFill(rect);
> NSColor *tempColor = [NSColor colorWithPatternImage:[NSImage
>imageNamed:@"myImage"]];
> [tempColor set];
> [NSBezierPath fillRect:rect];
>}
>
>And the view is still messed up when I scroll with bits of the image
>being drawn over one another. I tried changing the references to
>"rect" to [self bounds] but it made no difference.

<http://www.cocoabuilder.com/archive/message/2005/3/15/130496>

In other words, don't keep creating the color in your drawRect. Create it
once and store it in an NSImage, and use *that* in your drawRect.

m.

-- 
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.