所以我有这个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;
}
预先感谢!
最佳答案
尝试将内容模式设置为UIViewContentModeScaleAspectFit