简体   繁体   中英

UICollectionView offscreen screenshot

Is it possible to capture screenshot (with drawViewHierarchyInRect:afterScreenUpdates: ) before UICollectionView become visible ?

In my situation i have UIPageViewController with multiple views as pages. I want to capture screenshot before collection view is visible and add blur.

But drawView... method always return blank image, only after uicollectionview is completely visible this can return good screenshot?

Is there any way to force UICollectionView to render before it become visible?

It isn't just the collection view that you need to think about, it's also the view controller which supplies it with data. Often as well as loading the view you will need to run some logic in the controller to load the required data (often in viewWillAppear: ), and then once the data is available (which may be asynchronous) the collection view needs to be reloaded, which is asynchronous (and doesn't provide a completion callback, see this question for more details).

So, while it is possible to do what you want, you need to consider the data sourcing and asynchronous nature of loading data into the view before you will be able to get a non-blank image result.

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