I have successfully called the method:
-(UIImage *)chartImage {
// create an image context - the size of chart and the scale of the device screen
UIGraphicsBeginImageContextWithOptions(_chart.bounds.size, NO, 0.0);
// render our snapshot into the image context
[_chart drawViewHierarchyInRect:_chart.bounds afterScreenUpdates:NO];
// grab the image from the context
UIImage *chartImage = UIGraphicsGetImageFromCurrentImageContext();
// Finish using the context
UIGraphicsEndImageContext();
return chartImage;
}
This works if the chart is visible on the screen, howver if I create the chart but do not add it as a subview to display on screen then the above code produces the right sized image but it is blank?
I have a need to cycle through many charts and create a snapshot of each ready to export so it is not practical to display them momentarly in order to grab the image...
Should this method still work even if the chart is not visible but has been created?