Felix's Space

Never send to know for whom the bells tolls; it tolls for thee.

iOS 截屏拼图

iOS

1. 普通界面

ios 7 以后截图

ios7中添加了调用 snapshotViewAfterScreenUpdates 创建一个复合视图的快照。然后返回一个uiview对象来表示调用视图的整体外观。

Supplying YES for -snapshotViewAfterScreenUpdates: means it needs a trip back to the runloop to actually draw the image. If you supply NO, it will try immediately, but if your view is off screen or otherwise hasn’t yet drawn to the screen, the snapshot will be empty.

因为返回的是一个view对象,所以,你可以更改它以及它的layer属性.但是呢,你不能够修改它的layer的content属性;如果你试图这么做,将不会有任何效果.如果当前的view还没有渲染,或者这么说吧,因为还没有出现在屏幕上,那么,这个截取的view将不会有能显示的content.

如果你想要加载一个图形效果,比如blur,请使用这个方法 drawViewHierarchyInRect:afterScreenUpdates: 来代替.

22 Dec 2014 #iOS #snapshot