2013-09-26 32 views
2

我渲染多個圖層以獲得最終圖像。其中一個圖像包含一個臉部,另一個包含背景,臉部周圍有一個透明漸變,以便隱藏真實背景。在iOS6中它可以很好地工作,但它在iOS7中使用透明漸變創建了一個奇怪的效果。CALayer renderInContext iOS7

的代碼:

CGRect rect = [[UIScreen mainScreen] bounds]; 
UIGraphicsBeginImageContext(rect.size); 

CGContextRef context = UIGraphicsGetCurrentContext(); 

[faceImageView.layer renderInContext:context]; 
[fakeBackgroundImageView.layer renderInContext:context]; 

UIImage *img = UIGraphicsGetImageFromCurrentImageContext(); 
UIGraphicsEndImageContext(); 

在iOS6的和iOS7結果:

ios6

ios7

回答

6

好,將溶液改變這一行:

UIGraphicsBeginImageContext(rect.size); 

這一個:

UIGraphicsBeginImageContextWithOptions(rect.size, TRUE, [[UIScreen mainScreen] scale]); 

現在它也適用於iOS7

+0

謝謝......這是爲我工作 –