我刚刚完成了我的应用程序,并添加了一些伟大的事情与核心情节和他们敬业的工作人员的帮助。我的问题与在视网膜显示器上使用图像有关。我有一个注释,这是一张演讲气泡的图片。当我在模拟器中运行应用程序时,它显示正常分辨率,但当我切换到视网膜时,图像被裁剪。请看下面的图片。我有一个叫做气泡的.png,我添加了另一个叫做气泡@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);
}在这段代码之后,我放置了两个注释。正如您所看到的,一个可以工作,另一个不能。


发布于 2012-09-20 07:41:10
如果您需要支持视网膜图像,则应在创建CPTImage时传递图像scale。
CPTImage *fillimage = [CPTImage imageWithCGImage:bubble.CGImage
scale:bubble.scale];https://stackoverflow.com/questions/12494324
复制相似问题