简体   繁体   中英

Taking Screenshot of Bar Graph in iPhone

I am using core plot library to construct Bar Graph.

My issue is that I want to capture whole bar graph as Image so that user can mail it to their friends.

I searched and found

UIImage *newImage=[pieGraph imageOfLayer];

which actually captures current screen of graph, but as it is bar graph many of Bar in bar graph are going out of screen.

Is there any way to capture complete bar graph.

Thanks in advance.

The -imageOfLayer method only captures the current contents of a layer (eg, the graph) and its sublayers. If you want to make an image of a graph showing more data, you need to make another one that shows the desired data. It doesn't have to be onscreen in a hosting view--just create the graph and plot, give it the desired dimensions, and generate the image.

How to capture UIView to UIImage without loss of quality on retina display

This should work, depending on how the code display the graph is rendering. Failing that I'd just double check what the uiview in questions rect and bounds actually are to see whether it's doing some 'magic' to render the extra data rather than just keeping it offscreen and using transforms to let you scroll/zoom around. It's very similar to the previous answer but uses view bounds instead.

Try to capture screenshot. See this for more help

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM