// header NSImage *backgroundImg; - (id) initWithFrame:(NSRect)frameRect { if ( ( self = [super initWithFrame:framerect] ) != nil ) { NSString *szImgName = [[NSBundle mainBundle] pathForResource:@"img" ofType:@"png"]; backgroundImg = [[NSImage alloc] initWithContentsOfIle:szImgName]; } return self; } - (void) dealloc { [backgroundImg release]; [super dealloc]; } - (void) drawRect:(NSRect)rect { NSRect imgRect; NSRect drawRect; imgRect.origin = NSZeroPoint; imgRect.size = [backgroundImg size]; drawRect = [self bounds]; [backgroundImg drawInRect:drawRect fromRect:imgRect operation:NSCompositeSourceOver fraction:1.0]; }
개발관련/Mac