首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >情节框架外的图解图解

情节框架外的图解图解
EN

Stack Overflow用户
提问于 2014-12-05 18:25:10
回答 1查看 208关注 0票数 1

我有为OS应用程序图表,可以调整与窗口的大小。我预计,当宽度减少足够多时,图例将被截断或剪短。然而,它是溢出以外的地块,如下图所示。理想情况下,我希望图例截断或至少剪辑内容。这是如何做到的呢?

我的图例设置如下

代码语言:javascript
复制
- (void)configureLegend
{
    // 1 - Get graph instance
    CPTGraph *graph = self.graphHostingView.hostedGraph;
    // 2 - Create legend
    CPTLegend *theLegend;
    if (!theLegend) {
        theLegend = [CPTLegend legendWithGraph:graph];
    }

    //Configure Text
    CPTMutableTextStyle *textStyle = [CPTMutableTextStyle textStyle];
    textStyle.color = [CPTColor colorWithComponentRed:0.612f green:0.612f blue:0.612f alpha:1.00f];
    textStyle.fontName = @"HelveticaNeue";
    textStyle.fontSize = 12.0f;
    theLegend.textStyle = textStyle;

    // 3 - Configure legend
    theLegend.numberOfColumns = 1;
    theLegend.fill = nil;
    theLegend.borderLineStyle = nil;
    theLegend.swatchSize = CGSizeMake(10.0, 10.0);
    theLegend.swatchCornerRadius = 5.0f;
    // 4 - Add legend to graph
    graph.legend = theLegend;
    graph.legendAnchor = CPTRectAnchorLeft;
    CGFloat viewWidth = self.graphHostingView.bounds.size.width;
    CGFloat legendPadding = (viewWidth * 0.3) + self.pieChart.pieRadius + (viewWidth * 0.05);
    graph.legendDisplacement = CGPointMake(legendPadding, 0.0);
}

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-12-06 01:03:55

确保图表掩盖了它的子层。使用masksToBounds剪辑到边框线的外部,使用masksToBorder剪辑到边框的内部边缘。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27322344

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档