0

所以我在UIImageView它上面有一个图像。当我使用普通的 iPhone 显示器时,它会UIImageView完全按照预期在内部显示 - 在UIImageView边界内,问题是当我使用视网膜显示设备时,图像变大并且不符合UIImageView边界,一切正常在屏幕上。

我该如何解决这个问题?我希望 Retina 显示中的图像适合UIImageView尺寸。

这是我的代码:

- (UIImage *)loadScreenShotImageFromDocumentsDirectory
{
    UIImage * tempimage;
    NSArray *sysPaths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES );
    NSString *docDirectory = [sysPaths objectAtIndex:0];
    NSString *filePath = [NSString stringWithFormat:@"%@/MeasureScreenShot.png", docDirectory];
    tempimage = [[UIImage alloc] initWithContentsOfFile:filePath];

    return tempimage;
}

- (void)viewDidLoad
{
    // Setting the image
    UIImage * Image = [self loadScreenShotImageFromDocumentsDirectory];
    theImageView.frame = CGRectMake(0, 166, 290, 334);
    theImageView.contentMode = UIViewContentModeCenter;        
    theImageView.image = Image;
}

预先感谢!

4

2 回答 2

1

尝试将内容模式设置为UIViewContentModeScaleAspectFit

于 2012-10-25T13:28:23.280 回答
0

当我使用带有核心图的图像时,我必须为视网膜显示缩放图像。

 CPTImage *fillimage = [CPTImage imageWithCGImage:bubble.CGImage scale:bubble.scale];

图像文件的名称是气泡,我有一个气泡文件和一个气泡@2x 文件。这让图像适合任一显示的图像视图。希望这可以帮助。

于 2012-10-25T13:29:06.397 回答