UITableView/UIScrollView 分类为你提供真正简单、智能、瞬时的截图图像,适用于 iOS 5+ 设备。
这是一个在模拟器上的 tableview
这里是通过选择第一行获得的全屏截图图像
pod install
pod 'DHSmartScreenshot'
这将安装最佳版本的 DHSmartScreenshot。
或者你还可以将 Classes/
目录下的所有文件复制到你的项目中。确保已勾选 '将项目复制到目标文件夹的文件夹中'。
导入头文件: #import "DHSmartScreenshot.h"
调用
UIImage * tableViewScreenshot = [self.tableView screenshot];
以获取你的 tableView 实例的完整截图,或者查看以下内容以了解要调用的方法以及获取更符合你需求的定制截图。
有一些方法可以自定义截图的方式。每个方法都是自我描述性的,并且按预期工作,请参阅
- (UIImage *)screenshot;
- (UIImage *)screenshotOfCellAtIndexPath:(NSIndexPath *)indexPath;
- (UIImage *)screenshotOfHeaderViewAtSection:(NSUInteger)section;
- (UIImage *)screenshotOfFooterViewAtSection:(NSUInteger)section;
- (UIImage *)screenshotExcludingAllHeaders:(BOOL)withoutHeaders
excludingAllFooters:(BOOL)withoutFooters
excludingAllRows:(BOOL)withoutRows;
- (UIImage *)screenshotExcludingHeadersAtSections:(NSSet *)headerSections
excludingFootersAtSections:(NSSet *)footerSections
excludingRowsAtIndexPaths:(NSSet *)indexPaths;
- (UIImage *)screenshotOfHeadersAtSections:(NSSet *)headerSections
footersAtSections:(NSSet *)footerSections
rowsAtIndexPaths:(NSSet *)indexPaths;
- (UIImage *)screenshotOfVisibleContent;
当然 :) 请发送一个 pull-request 或提出一个问题。了解如何改进事情总是很好的,耶!
David Hernandez ([email protected])
DHSmartScreenshot 在 MIT 许可证下。