拍摄整个UIView的快照/屏幕快照-iPhone [英] Take snapshot / screenshot of whole UIView - iPhone
本文介绍了拍摄整个UIView的快照/屏幕快照-iPhone的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试截取UIView的屏幕快照/快照.我可以使用当前可见视图下面的代码获取屏幕截图-但是我需要整个视图.
I am trying to take a screenshot/snapshot of a UIView. I am able to get the a screenshot with the code below of the current visible view - but i am after the whole view.
该视图是滚动视图,因此下面没有我想被包含的内容
The view is a scrollview so there is content below that isnt visible that i would like to be included
如何扩展此代码以考虑不可见的视图?
How do i extend this code to take into account the view that isnt visible?
UIGraphicsBeginImageContext(activityView.frame.size);
[self.activityView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *fullScreenshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(fullScreenshot, nil, nil, nil);
推荐答案
iOS 7为类UIView
引入了一种新方法.
There is a new method introduced from iOS 7 for a class UIView
.
- (UIView *)snapshotViewAfterScreenUpdates:(BOOL)afterUpdates;
- (UIView *)resizableSnapshotViewFromRect:(CGRect)rect afterScreenUpdates:(BOOL)afterUpdates withCapInsets:(UIEdgeInsets)capInsets;
您可以使用此方法拍摄当前视图的屏幕截图.
You can use this method to take screenshots of your current view.
这篇关于拍摄整个UIView的快照/屏幕快照-iPhone的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文