Reputation:
I'm rendering multiple layers to get one final image. One of the images contains a face, and another one contains a background with a transparent gradient around the face so that the real background is hidden. In iOS6 it works perfectly but it is creating a weird effect with the transparent gradient in iOS7.
The code:
CGRect rect = [[UIScreen mainScreen] bounds];
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[faceImageView.layer renderInContext:context];
[fakeBackgroundImageView.layer renderInContext:context];
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
The results in iOS6 and iOS7:
Upvotes: 2
Views: 2632
Reputation:
Ok, the solution was changing this line:
UIGraphicsBeginImageContext(rect.size);
for this one:
UIGraphicsBeginImageContextWithOptions(rect.size, TRUE, [[UIScreen mainScreen] scale]);
Now it also works in iOS7
Upvotes: 6