最佳答案
将 centerAnchor
中的坐标乘以绘图区域 bounds
大小的相应部分,并将其添加到 x
或 y
边界的坐标 origin
。您可以使用计算出的点作为图层注释的 anchor 。
饼图在画图的时候是这样计算中心的:
CPTPlotArea *thePlotArea = self.plotArea;
CGRect plotAreaBounds = thePlotArea.bounds;
CGPoint anchor = self.centerAnchor;
CGPoint centerPoint = CPTPointMake(plotAreaBounds.origin.x + plotAreaBounds.size.width * anchor.x,
plotAreaBounds.origin.y + plotAreaBounds.size.height * anchor.y);
centerPoint = [self convertPoint:centerPoint fromLayer:thePlotArea];
if ( self.alignsPointsToPixels ) {
centerPoint = CPTAlignPointToUserSpace(context, centerPoint);
}
关于ios - 如何在核心情节饼图中心添加图片和标题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33730303/