Fill an NSView with a tile of NSImage
Fill an NSView with a tile of NSImage
- Subject: Fill an NSView with a tile of NSImage
- From: malcom <email@hidden>
- Date: Sat, 25 Feb 2006 01:13:20 +0100
Hello,
I've a problem with an NSView and NSImage.
I would to fill an NSView using a small image by duplicating it
n-times (tile?). I've tried using this code:
- (void)drawRect:(NSRect)rect {
int k;
NSRect tmp = [self bounds];
int repeat = (rect.size.width/7)+10;
for (k=4; k < repeat; k++) {
[[NSImage imageNamed:@"bar.tif"] drawInRect: tmp fromRect: [self
bounds] operation: NSCompositeSourceOver fraction:1.0];
tmp.origin.x = tmp.origin.x+7;
}
}
(or replacing [self bounds] with rect). Unfortunatly it seems to be
buggy because I've some problem when I try to add a control (ex.
search field) in front of the view.
This is an example: http://img507.imageshack.us/img507/847/prova8lv.jpg
I've solved a part of this problem by adding:
- (BOOL) isOpaque {
return YES;
}
but it does not works very well.
Now the background image draws well but I've still problems with focus ring.
This is an example:
http://img517.imageshack.us/img517/129/prova23of.jpg
Is there another way to solve this problem?
I would to replicate the background image as like in NetnewsWire
but... nothing :(
Anyone can help me?
thx
malcom
_______________________________________________
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