1
我在xy图中的自定义刻度位置绘制图标,并在iOS 5上使用Core Plot 1.0绘制散点图。我一直在iPad 3上出现性能问题允许用户交互并水平滚动图形。我开始考虑使用CPTGraphHostingView的collapsesLayers属性作为潜在的解决方案。除了我还没有解决的一个特殊问题外,启用它对我来说工作得很好。我设置的自定义轴标签不会显示。我想知道是否有人对可能的原因有任何想法。据我所知,轴标签仍然正确定位在正确的自定义刻度位置。我的外部代码唯一的区别是将collapsesLayers从NO交换到YES。核心绘图不显示包含图像的轴标签collapsesLayers为YES时
这里是我正在构建轴标签:
+ (CPTAxisLabel *)buildIconAxisLabelAtLocation:(CGFloat)location withImageNamed:(NSString *)imageName
{
CPTLayer *imageLayer = [[CPTLayer alloc] initWithFrame:CGRectMake(0, 0, 16, 16)];
UIImage *image = [UIImage imageNamed:imageName];
CALayer *imageSubLayer = [[CALayer alloc] init];
imageSubLayer.frame = imageLayer.frame;
imageSubLayer.contents = (id)image.CGImage;
[imageLayer addSublayer:imageSubLayer];
CPTAxisLabel *iconLabel = [[CPTAxisLabel alloc] initWithContentLayer:imageLayer];
iconLabel.offset = 8;
iconLabel.tickLocation = CPTDecimalFromCGFloat(location);
iconLabel.rotation = M_PI;
return iconLabel;
}
任何帮助表示赞赏。
这确实是问题。感谢Eric对你的回应以及Core Plot的工作。我只需做一个小调整:'CPTImage * background = [CPTImage imageWithCGImage:image.CGImage scale:[[UIScreen mainScreen] scale]];' –
@Eric如何在核心图中的CPTLayer上添加图像和文本? – Mayank