微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

UIView.snapshotView根据定义似乎是同步的,但充当异步

如何解决UIView.snapshotView根据定义似乎是同步的,但充当异步

我需要制作视图快照,以实现此目的,我想使用open func snapshotView(afterScreenUpdates afterUpdates: Bool) -> UIView? UIView函数。该函数似乎是同步的,因为它不是在闭包中而是直接返回视图。另一方面,这是此功能的正式定义,可以在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.

然后怎么可能在快照拍摄后(是同步的)捕获快照所做的更改?我试图在网络上找到一些相关信息,但是没有运气。也许有人可以向我解释一下?谢谢

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。