I need to make the snapshot of my view, to achieve this I'd like to use open func snapshotView(afterScreenUpdates afterUpdates: Bool) -> UIView?
UIView function. This function seems to be synchronous since it returns the view not in a closure but directly. On the other hand this is an official definition of this function that can be found in UIKit
/*
* When requesting a snapshot, 'afterUpdates' defines whether the snapshot is representative of what's currently on screen or if you wish to include any recent changes before taking the snapshot.
If called during layout from a committing transaction, snapshots occurring after the screen updates will include all changes made, regardless of when the snapshot is taken and the changes are made. For example:
- (void)layoutSubviews {
UIView *snapshot = [self snapshotViewAfterScreenUpdates:YES];
self.alpha = 0.0;
}
The snapshot will appear to be empty since the change in alpha will be captured by the snapshot. If you need to animate the view during layout, animate the snapshot instead.
Then how is this possible that the changes that are made after snapshot is taken(which is synchronous) will be captured by the snapshot ? I tried to find some info on this on the web, but no luck. Maybe someone can explain this to me? Thank you