I implemented corePlot into my xcode
project. I'm trying to add the legend
to another
cell
.
I'm able to add the legend
to another cell, but when I do that, the text is upside down.
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);
}
That didn't do anything. The results where the same. Why is this happening, and how can I get the text to show normally, not upside down?
Edit
This is how it shows when I add it as a subLayer: (It says: "First", "Second".)
Try M_PI / 2.0f
which is in radians. Using 180.0f (presumably degrees) does not make sense in the context of this function.
Core Plot applies a flip transform on iOS so we can use the same drawing code on both the Mac and iOS. This is the transform it uses:
self.layer.sublayerTransform = CATransform3DMakeScale( CPTFloat(1.0), CPTFloat(-1.0), CPTFloat(1.0) );
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.