cocoa objective-c: Change background color of custom view
If I have a bunch of custom views that I 开发者_开发知识库made in IB, how can I set up a background color for each when the app awakesFromNib?
In your NSView subclass:
- (void)drawRect:(NSRect)aRect
{
[[NSColor redColor] set];
NSRectFill([self bounds]);
}
精彩评论