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