私はちょうど私のアプリを使い果たし、コアプロットと彼らの献身的なスタッフの助けを借りていくつかの素晴らしいものを追加しました。私の質問は、Retinaディスプレイで画像を使用することに関するものです。ふきだしの絵の注釈があります。シミュレーターでアプリを実行すると、通常の解像度では正常に表示されますが、網膜に切り替えると、画像がトリミングされます。下の写真を参照してください。バブルと呼ばれる.pngがあり、2倍のサイズのBubble @ 2xと呼ばれる別の.pngを追加しました。これが、私が行う必要があることだと思いました。それはうまくいきませんでした。そこで、view.contentScaleを設定しようとしました。以下のコードを参照してください。しかし、何も機能していないようです。誰かが私がするのを忘れていることについて何か考えがありますか?もう一度ありがとう。
{
//first annotation
NSValue *value = [self.myData objectAtIndex:index];
CGPoint point = [value CGPointValue];
NSString *number1 = [NSString stringWithFormat:@"(%.2f, ", point.x];
NSString *number2 = [NSString stringWithFormat:@"%.2f)", point.y];
NSNumber *x = [NSNumber numberWithFloat:point.x];
NSNumber *y = [NSNumber numberWithFloat:point.y];
NSArray *anchorPoint = [NSArray arrayWithObjects: x, y, nil];
NSString *final = [number1 stringByAppendingString:number2];
//second annotation
UIImage *bubble = [UIImage imageNamed:@"Bubble.png"];
CPTImage *fillimage = [CPTImage imageWithCGImage:bubble.CGImage];
CPTBorderedLayer *imageLayer = [[CPTBorderedLayer alloc] init];
//imageLayer.contentsScale = [[UIScreen mainScreen] scale]; //tried this
imageLayer.frame = CGRectMake(0, 0, 150, 80);
//imageLayer.contentsScale = 2.0f; //and this
imageLayer.fill = [CPTFill fillWithImage:fillimage];
CPTTextLayer *textLayer = [[CPTTextLayer alloc] initWithText:final style:annotationTextStyle];
_annotation = [[CPTPlotSpaceAnnotation alloc] initWithPlotSpace:graph.defaultPlotSpace anchorPlotPoint:anchorPoint];
_annotation.contentLayer = textLayer;
_annotation.displacement = CGPointMake(90.0f, 5.0f);
_annotation.rotation = M_PI * .03f;
_picAnnotation = [[CPTPlotSpaceAnnotation alloc] initWithPlotSpace:graph.defaultPlotSpace anchorPlotPoint:anchorPoint];
_picAnnotation.contentLayer = imageLayer;
_picAnnotation.displacement = CGPointMake(75.0f, 5.0f);
}
そのコードの後に、両方の注釈を配置しました。ご覧のとおり、一方は機能しますが、もう一方は機能しません。