Iphone 只读属性上的Core Plot CPLineStyle编译错误

Iphone 只读属性上的Core Plot CPLineStyle编译错误,iphone,objective-c,ipad,ios,Iphone,Objective C,Ipad,Ios,试图构建核心图并使用CPLineStyle,我从这段代码中得到一个编译错误 CPLineStyle *lineStyle = [CPLineStyle lineStyle]; lineStyle.lineColor = [CPColor blackColor]; 错误:无法设置对象-找不到只读属性或setter 属性是@synthesis'd,当它被声明时 @property (nonatomic, readonly, retain) CPColor *lineColor; 在标题中,它在类

试图构建核心图并使用CPLineStyle,我从这段代码中得到一个编译错误

CPLineStyle *lineStyle = [CPLineStyle lineStyle];
lineStyle.lineColor = [CPColor blackColor];
错误:无法设置对象-找不到只读属性或setter

属性是@synthesis'd,当它被声明时

@property (nonatomic, readonly, retain) CPColor *lineColor;
在标题中,它在类别中被重新声明为

@property (nonatomic, readwrite, retain) CPColor *lineColor;
编译器似乎不知道属性的重新声明。这里怎么了


冈萨洛

请用这种方式,这对我来说很有效

CPMutableLineStyle *plotlineStyle = [CPLineStyle lineStyle];
plotlineStyle.lineColor = [CPColor whiteColor];
plotlineStyle.lineWidth = 2.0f;

然后将此样式应用于axis或使用CPMutableTextStyle对textstyle执行的任何类似操作。

您需要CPTMutableLineStyle(而不是CPLineStyle)

因此,改变:

CPLineStyle *lineStyle = [CPLineStyle lineStyle];
致:


这些属性仅在CPLineStyle实现文件中具有作用域。应改用CPMutableLineStyle。
CPTMutableLineStyle *lineStyle = [CPTMutableLineStyle lineStyle];