问题
I am using the following code to capture a UIView as a UIImage and save it in Docs Dir.
- (UIImage *) imageWithView:(UIView *)view
{
UIGraphicsBeginImageContext(view.bounds.size);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage * img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;
}
The UIImage is successfully saved. However the resolution is very poor. See the image below for reference. How do I make sure the resolution is retained as per the original image?
回答1:
Use UIGraphicsBeginImageContextWithOptions instead of UIGraphicsBeginImageContext
UIGraphicsBeginImageContextWithOptions(view.bounds.size, NO, 0.0);
Tell me its working or not :)
回答2:
Capture the image of Entire view using below code :-
UIGraphicsBeginImageContext(view.frame.size);
来源:https://stackoverflow.com/questions/18229251/converting-uiview-to-uiimage-gives-poor-quality