我刚刚完成了我的应用程序,并在核心情节和他们敬业的员工的帮助下添加了一些很棒的东西。我的问题涉及使用视网膜显示器的图像。我有一个注释,是一个讲话泡泡的图片。当我在模拟器中运行应用程序时,它显示正常分辨率,但当我切换到视网膜时,图像被裁剪。见下图。我有一个.png,我称之为Bubble,我又添加了另一个名为Bubble @ 2x的大小两倍,我认为这是我需要做的。那没用。所以我试着设置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);
}
在该代码之后,我随后放置了两个注释。你可以看到一个有用,另一个没有。
答案 0 :(得分:6)
如果您需要支持Retina图像,则应在创建scale
时传递图像CPTImage
。
CPTImage *fillimage = [CPTImage imageWithCGImage:bubble.CGImage
scale:bubble.scale];