If you call [view snapshotViewAfterScreenUpdates:NO] on a view that hasn't been displayed yet, you get:
Snapshotting a view that has not been rendered results in an empty snapshot. Ensure your view has been rendered at least once before snapshotting or snapshot after screen updates.
This goes away by changing the param to YES, which makes sense. Passing YES has a performance hit, and I don't need "after screen updates" unless it hasn't been displayed yet. Is there a way to know when passing in NO will cause that error, so that I can pass in YES only in that scenario?
I tried [view snapshotViewAfterScreenUpdates:view.layer.needsDisplay], but that didn't do it.
I don't think UIView
exposes whether or not it has unrendered changes. I usually only pass NO
when I know (based on context) that the view has already been displayed, such as when creating a snapshot for a view that is about to be removed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With