Why is the text inverted?

I have implemented corePlot in my project xcode

. I am trying to add legend

enter image description hereto another cell

.

I can add legend

to another cell, but when I do, the text is flipped.

Here is my code:

- (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];

      

This is what I tried:

    theLegend.transform = CATransform3DMakeRotation(M_PI / 180.0f, 0, 1, 0);
}

      

It didn't do anything. Results in the same place. Why is this happening, and how can I get the text to display normally and not upside down?

Edit

This is shown when I add it as a sublayer: enter image description here(It says "First", "Second".)

+3


source to share


2 answers


Core Plot applies flip transform on iOS, so we can use the same drawing code on both Mac and iOS. This is the transformation it uses:



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

      

0


source


Try M_PI / 2.0f

which is in radians. Using 180.0f (presumably degrees) doesn't make sense in the context of this function.



0


source







All Articles