我在我的corePlot项目中实现了xcode
。我正在尝试添加legend
另一个cell
。
我可以将legend
添加到另一个单元格中,但是当我这样做时,文本就颠倒了。
这是我的代码:
- (void)configureLegend
{
CPTGraph *graph = self.hostView.hostedGraph;
CPTLegend *theLegend = [CPTLegend legendWithGraph:graph];
// Add legend to graph
graph.legend = theLegend;
graph.legendAnchor = CPTRectAnchorRight;
CGFloat legendPadding = - (self.chartView.bounds.size.width / 8);
graph.legendDisplacement = CGPointMake(legendPadding, 0.0);
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:2 inSection:0]];
[cell.layer addSublayer:graph.legend];
这就是我试过的:
theLegend.transform = CATransform3DMakeRotation(M_PI / 180.0f, 0, 1, 0);
}
什么都没做。结果是一样的。为什么会发生这种情况,我怎样才能让文本正常显示,而不是颠倒过来呢?
编辑
当我将它作为一个subLayer添加时,它就是这样显示的:
(上面写着:“第一”,“第二”。)
发布于 2015-04-28 03:37:29
核心绘图在iOS上应用一个翻转转换,这样我们就可以在Mac和iOS上使用相同的绘图代码。这是它使用的转换:
self.layer.sublayerTransform = CATransform3DMakeScale( CPTFloat(1.0), CPTFloat(-1.0), CPTFloat(1.0) );
发布于 2015-04-27 19:15:39
试试M_PI / 2.0f
,它是弧度的。在这个函数的上下文中,使用180.0f (想必是度)是没有意义的。
https://stackoverflow.com/questions/29908998
复制