屏幕快照相关方法
extension UIView {/*
* 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.* Creating snapshots from existing snapshots (as a method to duplicate, crop or create a resizable variant) is supported. In cases where many snapshots are needed, creating a snapshot from a common superview and making subsequent snapshots from it can be more performant. Please keep in mind that if 'afterUpdates' is YES, the original snapshot is committed and any changes made to it, not the view originally snapshotted, will be included.
*/
@available(iOS 7.0, *)
open func snapshotView(afterScreenUpdates afterUpdates: Bool) -> UIView?@available(iOS 7.0, *)
open func resizableSnapshotView(from rect: CGRect, afterScreenUpdates afterUpdates: Bool, withCapInsets capInsets: UIEdgeInsets) -> UIView? // Resizable snapshots will default to stretching the center// Use this method to render a snapshot of the view hierarchy into the current context. Returns NO if the snapshot is missing image data, YES if the snapshot is complete. Calling this method from layoutSubviews while the current transaction is committing will capture what is currently displayed regardless if afterUpdates is YES.
@available(iOS 7.0, *)
open func drawHierarchy(in rect: CGRect, afterScreenUpdates afterUpdates: Bool) -> Bool
}
return view
faster
- (UIView *)snapshotViewAfterScreenUpdates:(BOOL)afterUpdates;
- (UIView *)resizableSnapshotViewFromRect:(CGRect)rect afterScreenUpdates:(BOOL)afterUpdates withCapInsets:(UIEdgeInsets)capInsets;
【屏幕快照相关方法】return image
slower
- (BOOL)drawViewHierarchyInRect:(CGRect)rect afterScreenUpdates:(BOOL)afterUpdates;
推荐阅读
- 屏幕另一边的纠结
- 思维导图作业3—工作相关导图
- AnyProxy抓取http/https请求
- day16-Linux|day16-Linux 软件管理
- 适合写进作文与疫情相关的句子|适合写进作文与疫情相关的句子|你看 爱和希望蔓延的比病毒更快 每一种爱 都刻进武汉的心脏
- Linux|Linux 服务器nginx相关命令
- iOS开发之屏幕快照被拒
- linux环境变量相关操作
- iOS|iOS 系统相关复习
- 初识html标签