【问题标题】:Core Plot CPLineStyle compile error on readonly property只读属性上的核心绘图 CPLineStyle 编译错误
【发布时间】:2011-02-09 02:48:20
【问题描述】:

尝试构建 Core Plot 并使用 CPLineStyle 我收到此代码的编译错误...

CPLineStyle *lineStyle = [CPLineStyle lineStyle];
lineStyle.lineColor = [CPColor blackColor];

错误:无法设置对象 - 只读属性或未找到设置器

该属性是 @synthesize'd 并且在声明时

@property (nonatomic, readonly, retain) CPColor *lineColor;

在标题中,它在类的类别中重新声明为

@property (nonatomic, readwrite, retain) CPColor *lineColor;

编译器似乎不知道该属性的重新声明。这里有什么问题?

贡萨洛

【问题讨论】:

  • 这些属性仅在 CPLineStyle 实现文件中具有作用域。应该改用 CPMutableLineStyle。

标签: iphone objective-c ipad ios


【解决方案1】:

请使用对我有用的这种方式...

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

然后将此样式应用于轴或您可以使用 CPMutableTextStyle 为 textstyle 执行的任何类似操作..

【讨论】:

    【解决方案2】:

    您需要 CPTMutableLineStyle(而不是 CPLineStyle)。

    所以,改变:

    CPLineStyle *lineStyle = [CPLineStyle lineStyle];
    

    收件人:

    CPTMutableLineStyle *lineStyle = [CPTMutableLineStyle lineStyle];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-30
      • 1970-01-01
      • 1970-01-01
      • 2011-03-07
      • 1970-01-01
      相关资源
      最近更新 更多