Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xcode n收集视图背景色完全填充_Xcode_Cocoa_Background Color_Nscollectionview - Fatal编程技术网

Xcode n收集视图背景色完全填充

Xcode n收集视图背景色完全填充,xcode,cocoa,background-color,nscollectionview,Xcode,Cocoa,Background Color,Nscollectionview,我有NcollectionView,想设置它的背景色,但是使用堆栈上这里建议的一些代码,我遇到了一个问题——它们都没有完全填满窗口。您可能会在nscollection视图周围看到白色(约1px)边框,但角落除外(集合视图约束设置为0) 理想情况下,我想摆脱白色的边界 第一个图像的代码: - (void)drawRect:(NSRect)dirtyRect { [super drawRect:dirtyRect]; CGContextRef context = (CGContextRef) [[

我有NcollectionView,想设置它的背景色,但是使用堆栈上这里建议的一些代码,我遇到了一个问题——它们都没有完全填满窗口。您可能会在nscollection视图周围看到白色(约1px)边框,但角落除外(集合视图约束设置为0)

理想情况下,我想摆脱白色的边界

第一个图像的代码:

- (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));
}

第二个图像的代码:

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

是否已打开自动布局?有项目警告吗?转到MainMenu.xib并查看右侧信息面板。如果是,则对约束进行处理。

是否打开了自动布局?有项目警告吗?转到MainMenu.xib并查看右侧信息面板。如果是,则对约束进行处理