I'm reading pdf's in a view and trying to capture screenshots of pdf pages. UIGraphicsGetImageFromCurrentImageContext() doesn't wor开发者_C百科k. any solutions?
That only works when the current image context is relevant, for instance if you are calling this within the drawRect method of a UIView then you have the context relating to the view.
Instead you need to create a new graphics context and render the view into it...
UIGraphicsBeginImageContext(view.size);
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGRect area = CGRectMake(0, 0, view.size.width, view.size.height);
CGContextDrawImage(ctx, area, view.layer.CGImage);
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
This is from memory so I hope this is correct but you get the idea....
精彩评论