2012-10-25 47 views
0

所以我有這個UIImageView與頂部的圖像。當我使用普通的iPhone顯示器時,它在UIImageView內部顯示的內容完全如其所示 - 在UIImageView範圍內,問題在於當我使用視網膜顯示設備時,圖像變大並且不符合UIImageView範圍,它遍佈屏幕。UIImageView contentMode在視網膜和非視網膜顯示不同

我該如何解決這個問題?我希望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; 
} 

預先感謝!

回答

1

嘗試當我使用具有核心情節的圖像內容模式設置爲UIViewContentModeScaleAspectFit

+0

非常感謝!完美的作品! –

0

,我不得不縮減圖像的Retina顯示屏。

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

的圖像文件的名字是泡沫,我有一個泡沫文件和泡沫@ 2個文件。這使圖像適合任一顯示的圖像視圖。希望這可以幫助。

相關問題