0

I just started using CorePlot library, and so far I'm managing to get stuff done.

I'm trying to create a piechart with some dummy data and more or less everything works as expected but for the life of me I cannot find how to style the legend items to make them look something like this:core plot legend

I can style the entire legend with background color, borders like this:

theLegend.numberOfColumns = 1;
theLegend.fill = [CPTFill fillWithColor:[CPTColor whiteColor]];
theLegend.borderLineStyle = [CPTLineStyle lineStyle];
theLegend.cornerRadius = 5.0;

as well as swatch size and row margin like this:

theLegend.swatchSize = CGSizeMake(7, 50);
theLegend.rowMargin = 5.0;

etc, but is there any way to style the individual rows of the legend backgrounds and borders?

If not, how would you suggest me to solve this?

Thank you for any help, cheers

4

1 回答 1

1

您可以使用-attributedLegendTitleForPieChart:recordIndex:饼图数据源方法为每个图例条目提供标签文本。属性字符串可以表示文本颜色、粗体文本和不同的文本大小。有关演示,请参阅Plot Gallery示例应用程序中的“简单饼图” 。在字符串中插入换行符 ( \n) 以生成第二行文本。

目前无法将图例条目背景与整个图例的背景分开设置样式。请向 Core Plot问题跟踪器添加增强请求。

您可以使用注释构建自己的自定义图例。使用 aCPTBorderedLayer作为背景并为每个图例条目添加图层注释。使用 aCPTBorderedLayer绘制样本,使用 aCPTTextLayer绘制文本标签。

于 2013-10-17T00:39:39.103 回答