【问题标题】:Why is the text upside down?为什么文字是颠倒的?
【发布时间】:2015-04-28 01:59:03
【问题描述】:

我在我的xcode 项目中实现了corePlot。我正在尝试将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);
}

这并没有做任何事情。结果哪里一样。为什么会发生这种情况,我怎样才能让文本正常显示,而不是颠倒?

编辑

当我将它添加为子层时,它是这样显示的:(上面写着:“第一”、“第二”。)

【问题讨论】:

    标签: ios objective-c core-plot


    【解决方案1】:

    Core Plot 在 iOS 上应用了翻转变换,因此我们可以在 Mac 和 iOS 上使用相同的绘图代码。这是它使用的转换:

    self.layer.sublayerTransform = CATransform3DMakeScale( CPTFloat(1.0), CPTFloat(-1.0), CPTFloat(1.0) );
    

    【讨论】:

    • 我做了 cell.layer.sub.... 里面的所有东西都颠倒了。然后我尝试了Legend.layer.sub....它说我不能做.layer???
    • 传说CALayer。直接设置transform就可以了。
    • 我试过theLegend.sublayer... 并没有对图例做任何事情
    • 顾名思义,sublayerTransform 只影响子层。设置transform 影响图层及其子图层。
    【解决方案2】:

    试试M_PI / 2.0f,它以弧度表示。在这个函数的上下文中使用 180.0f(大概是度数)没有意义。

    【讨论】:

    • 还是不行。我认为问题在于,我尝试访问图例的方式。因为无论我输入什么值,它都不会改变。
    猜你喜欢
    • 1970-01-01
    • 2020-11-21
    • 1970-01-01
    • 2013-02-01
    • 1970-01-01
    • 2017-03-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多