I have a view which I created in IB. I have the graphic file in my resource folder. I’m trying to fill the view with the graphic as a repeating (x and y) graphic (it’ll make a grid).
Here’s my code:
-(void) awakeFromNib {
//set background patterns using, loading it through NSImage
[[NSColor colorWithPatternImage:[NSImage imageNamed:@"ts_bg_pattern.png"]] set];
NSRect splashFrame = [splashScreen frame];
//fill view with background pattern
[NSBezierPath fillRect:[splashScreen bounds]];
sleep(5);
if (splashFrame.origin.x == 0) {
[[splashScreen animator] setFrame:NSMakeRect(-1123.0, 0.0, 212.0, 612.0)];
}
}
This compiles but does nothing. I’m pretty sure my error is with the NSBezierPath. Any help would be appreciated.
This won’t work in
awakeFromNib. You should implementdrawRect:in your view subclass, and put the drawing code there. Also you should useNSRectFill()to fill a rectangle.