Tiled background image in a scrolling custom view
Tiled background image in a scrolling custom view
- Subject: Tiled background image in a scrolling custom view
- From: Mark Alldritt <email@hidden>
- Date: Fri, 25 Apr 2003 13:51:01 -0700
Hi,
I'm trying to displayed a tiled image as the background of a custom NSView
embedded within an NSScrollView. The problem is that when I scroll
horizontally the background image is not drawn properly (the repeating
patter does not line up in the areas that scroll into view). Also, when I
resize vertically, the image is anchored to the bottom of the view.
Here's the code I'm playing with:
#import "MyView.h"
@implementation MyView
static NSColor* sBackgroundColor = nil;
- (id) initWithFrame:(NSRect) frameRect
{
[super initWithFrame:frameRect];
if (!sBackgroundColor)
{
sBackgroundColor = [NSColor colorWithPatternImage:[NSImage
imageNamed:@"background"]];
[sBackgroundColor retain];
}
[self setFrameSize:NSMakeSize(2500.0, 1500.0)];
return self;
}
- (void) drawRect:(NSRect) rect
{
[sBackgroundColor set];
NSRectFill([self bounds]);
}
- (BOOL) isOpaque
{
return YES;
}
@end
What am I doing wrong? I've tried flipping the view, but that did nothing.
Cheers
-Mark
---------------------------------------------------------------------
Mark Alldritt Late Night Software Ltd.
Phone: 250-380-1725 333 Moss Street
FAX: 250-383-3204 Victoria, B.C.
WEB:
http://www.latenightsw.com/ CANADA V8V-4M9
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.