gpt4 book ai didi

Cocoa CGColorRef 不兼容的指针类型传递 float [4 ]' to parameter of type ' const CGFloat *' (aka ' const double *')

转载 作者:行者123 更新时间:2023-12-03 17:52:40 26 4
gpt4 key购买 nike

我收到此错误:

my color = CGColorCreate(colorSpace, fillComponents); variable: incompatible pointer types passing 'float [4]' to parameter of type 'const CGFloat *' (aka 'const double *'). 

如何解决这个问题?

CGColorRef color;

//retrieve some usefull rects
NSRect frame = [self frame];
NSRect imageFrame = [self imageFrame];
NSRect relativeImageFrame = NSMakeRect(imageFrame.origin.x - frame.origin.x, imageFrame.origin.y - frame.origin.y, imageFrame.size.width, imageFrame.size.height);

/* place holder layer */
if(type == IKImageBrowserCellPlaceHolderLayer){
//create a place holder layer
CALayer *layer = [CALayer layer];
layer.frame = CGRectMake(0, 0, frame.size.width, frame.size.height);

CALayer *placeHolderLayer = [CALayer layer];
placeHolderLayer.frame = *(CGRect*) &relativeImageFrame;

float fillComponents[4] = {1.0, 1.0, 1.0, 0.3};
float strokeComponents[4] = {1.0, 1.0, 1.0, 0.9};
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();

//set a background color
color = CGColorCreate(colorSpace, fillComponents);
[placeHolderLayer setBackgroundColor:color];
CFRelease(color);

//set a stroke color
color = CGColorCreate(colorSpace, strokeComponents);
[placeHolderLayer setBorderColor:color];
CFRelease(color);

[placeHolderLayer setBorderWidth:2.0];
[placeHolderLayer setCornerRadius:0];
CFRelease(colorSpace);

[layer addSublayer:placeHolderLayer];

return layer;
}

最佳答案

如果您按照错误消息的建议定义填充/描边组件,它应该可以工作:

const CGFloat *components = {1.0, 1.0, 1.0, 0.3};

关于Cocoa CGColorRef 不兼容的指针类型传递 float [4 ]' to parameter of type ' const CGFloat *' (aka ' const double *'),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21531314/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com