【问题标题】:How can I wrap the text added to the plot using core plot library in iphone sdk如何使用 iphone sdk 中的核心绘图库包装添加到绘图中的文本
【发布时间】:2011-10-21 13:30:44
【问题描述】:

我已经像这样在饼图中添加了标签 -(CPTLayer *)dataLabelForPlot:(CPTPlot *)绘图记录索引:(NSUInteger)索引 {

CPTTextLayer *newLayer = nil;
UIFont *theFont;

static CPTMutableTextStyle *whiteText = nil;

if ( !whiteText )
{
    whiteText = [[CPTMutableTextStyle alloc] init];
    whiteText.color = [CPTColor blackColor];
    whiteText.textAlignment = CPTTextAlignmentCenter;
    whiteText.fontName = @"Helvetica-Bold";
    whiteText.fontSize =  10.0f;
   theFont = [UIFont fontWithName:whiteText.fontName size:whiteText.fontSize];


}
if ( [plot isKindOfClass:[CPTPieChart class]] ) 
{
    newLayer.delegate = self;
    newLayer = [[[CPTTextLayer alloc] initWithText:[NSString stringWithFormat:@"%@", [pieChartData2 objectAtIndex:index]] style:whiteText] autorelease];
      }

return newLayer;
    }

我想要的是 (1)我想换行太长的文本。 (2) 我想显示 Slice 的标题和它的值。 (3) 我需要在 title 和 Slice 上画一条线。 请任何人帮助我。

提前致谢

【问题讨论】:

    标签: objective-c ios4 core-plot


    【解决方案1】:
    1. 您可以在文本中插入换行符 ('\n') 以换行到下一行。 Core Plot 不会自动换行任何文本。

    2. 这是一个数据源方法——它应该可以访问数据值和标题。使用两者来构建标签字符串。

    3. 尚不支持在标签上画线。您可以创建 CPTTextLayer 的自定义子类,除了文本之外还绘制线条,并使用它而不是库存 CPTTextLayer 来制作标签。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-05-22
      • 1970-01-01
      • 2011-07-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多