gpt4 book ai didi

cocoa - Coreplot 图例在图框之外绘制

转载 作者:行者123 更新时间:2023-12-03 17:11:10 25 4
gpt4 key购买 nike

我有 OS X 应用程序的图表,可以随窗口调整大小。我预计当宽度减小得足够多时,图例将被截断或剪裁。然而,它溢出到绘图区域之外,如下所示。理想情况下,我希望图例截断或至少剪辑内容。如何做到这一点?

我的图例设置如下

- (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);
}

Legend Not Clipping

最佳答案

确保图形遮盖了其子图层。使用 masksToBounds 剪裁到边框线的外部,或使用 masksToBorder 剪裁到边框的内边缘。

关于cocoa - Coreplot 图例在图框之外绘制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27322344/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com