2013-04-25 25 views
1

我有幾個UIVies邊緣到邊緣。視圖完全覆蓋了superView。看起來不錯,但是當呈現相鄰的邊緣可見時,就是在它們之間出現一條線。由於視圖看起來非常完美,所以我認爲它必須是導致這種情況的視圖像素的插值。renderInContext之後的插值問題:UIGraphicsGetCurrentContext(),iOS

任何人都知道如何解決這個問題?

下面的圖像是一個渲染。在設備或模擬器上,線條不可見。 enter image description here

渲染代碼

-(void)renderImage { 
    CGSize renderSize = CGSizeMake(masterView.frame.size.width, masterView.frame.size.height); 
    UIGraphicsBeginImageContext(renderSize); 
    CGContextRef context = UIGraphicsGetCurrentContext(); 
    CGContextSaveGState(context); 
    CGContextConcatCTM(context, [[masterView layer] affineTransform]); 
    [[masterView layer] renderInContext:UIGraphicsGetCurrentContext()]; 
    renderedImage = UIGraphicsGetImageFromCurrentImageContext(); 
    UIGraphicsEndImageContext(); 
    CGContextRestoreGState(context); 
    UIImageWriteToSavedPhotosAlbum(renderedImage, self, @selector(image:didFinishSavingWithError:contextInfo:), nil); 
    masterView.transform = CGAffineTransformIdentity; 
} 
+0

你解決這個問題?我在開發我的應用程序時遇到了同樣的問題。 – Eleanore 2013-09-20 15:26:52

回答

-1

嘗試:

UIGraphicsBeginImageContextWithOptions(renderSize, false, [[UIScreen mainScreen] scale]); 

代替:

UIGraphicsBeginImageContext(renderSize); 
+0

感謝您的建議!到目前爲止,這並沒有解決問題。任何提示爲什麼你提出這個建議,可能會有所幫助。 – Mrwolfy 2013-04-26 04:19:44

0

核芯顯卡企圖抗混你的意見。你需要告訴它不要這樣做。

請看下面的例子呈現自我,一個UIView,因爲沒有抗鋸齒一個UIImage:

UIGraphicsBeginImageContextWithOptions(self.bounds.size, YES, [[UIScreen mainScreen] scale]); 
CGContextSetAllowsAntialiasing(UIGraphicsGetCurrentContext(), FALSE); 
[self.layer renderInContext:UIGraphicsGetCurrentContext()]; 
UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 
UIGraphicsEndImageContext();