NSCollection view background color filling entirely

561 views Asked by At

I have NSCollectionView and would like to set its background color, however using some of codes suggested here on stack I came to a problem - none of them fill the window entirely. You might be able to see a white (around 1px) white border around nscollection view except of the corners (collection view constraints are set to 0).

Ideally I would like to get rid of the white border.

Code for the first image:

- (void)drawRect:(NSRect)dirtyRect {
[super drawRect:dirtyRect];

CGContextRef context = (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort];
CGContextSetRGBFillColor(context, 0.227,0.251,0.337,1);
CGContextFillRect(context, NSRectToCGRect(dirtyRect));
}

First Image

Code for the second image:

- (void)drawRect:(NSRect)dirtyRect {
[super drawRect:dirtyRect];
[[NSColor blueColor] setFill];
NSRectFill(dirtyRect);
}

Second Image

1

There are 1 answers

0
Yaro On

Do you have Autolayout turned on? Any project warning? Go to MainMenu.xib and look in the right info panel. If Yes, then do something with the constraints.