├── .gitignore ├── Classes ├── DHSmartScreenshot.h ├── Swift │ ├── UIImage+Additions.swift │ ├── UIScrollView+Additions.swift │ ├── UITableView+Additions.swift │ └── UIView+Additions.swift ├── UIImage+DHImageAdditions.h ├── UIImage+DHImageAdditions.m ├── UIScrollView+DHSmartScreenshot.h ├── UIScrollView+DHSmartScreenshot.m ├── UITableView+DHSmartScreenshot.h ├── UITableView+DHSmartScreenshot.m ├── UIView+DHSmartScreenshot.h └── UIView+DHSmartScreenshot.m ├── DHSmartScreenshot.podspec ├── Example ├── Storyboard.storyboard ├── TableViewScreenshots.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── TableViewScreenshots │ ├── DHAppDelegate.h │ ├── DHAppDelegate.m │ ├── DHMainViewController.h │ ├── DHMainViewController.m │ ├── DHScreenshotViewController.h │ ├── DHScreenshotViewController.m │ ├── Images.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ └── LaunchImage.launchimage │ │ │ └── Contents.json │ ├── TableViewScreenshots-Info.plist │ ├── TableViewScreenshots-Prefix.pch │ ├── en.lproj │ │ └── InfoPlist.strings │ └── main.m └── TableViewScreenshotsTests │ ├── TableViewScreenshotsTests-Info.plist │ ├── TableViewScreenshotsTests.m │ └── en.lproj │ └── InfoPlist.strings ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | .DS_Store 3 | */build/* 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | profile 14 | *.moved-aside 15 | DerivedData 16 | .idea/ 17 | *.hmap 18 | *.xccheckout 19 | 20 | #CocoaPods 21 | Pods 22 | -------------------------------------------------------------------------------- /Classes/DHSmartScreenshot.h: -------------------------------------------------------------------------------- 1 | // 2 | // DHSmartScreenshot.h 3 | // TableViewScreenshots 4 | // 5 | // Created by Hernandez Alvarez, David on 12/3/13. 6 | // Copyright (c) 2013 David Hernandez. All rights reserved. 7 | // 8 | 9 | #ifndef TableViewScreenshots_DHSmartScreenshot_h 10 | #define TableViewScreenshots_DHSmartScreenshot_h 11 | 12 | #import "UITableView+DHSmartScreenshot.h" 13 | #import "UIScrollView+DHSmartScreenshot.h" 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /Classes/Swift/UIImage+Additions.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import UIKit 3 | 4 | extension UIImage { 5 | 6 | class func imageWithColor(color:UIColor, size:CGSize) -> UIImage? { 7 | UIGraphicsBeginImageContextWithOptions(size, false, UIScreen.main.scale) 8 | let context = UIGraphicsGetCurrentContext() 9 | if context == nil { 10 | return nil 11 | } 12 | color.set() 13 | context?.fill(CGRect(x: 0, y: 0, width: size.width, height: size.height)) 14 | let image = UIGraphicsGetImageFromCurrentImageContext() 15 | UIGraphicsEndImageContext() 16 | return image 17 | } 18 | } 19 | 20 | extension UIImage { 21 | 22 | class func verticalAppendedTotalImageSizeFromImagesArray(imagesArray:[UIImage]) -> CGSize { 23 | var totalSize = CGSize.zero 24 | for im in imagesArray { 25 | let imSize = im.size 26 | totalSize.height += imSize.height 27 | totalSize.width = max(totalSize.width, imSize.width) 28 | } 29 | return totalSize 30 | } 31 | 32 | 33 | class func verticalImageFromArray(imagesArray:[UIImage]) -> UIImage? { 34 | 35 | var unifiedImage:UIImage? 36 | let totalImageSize = self.verticalAppendedTotalImageSizeFromImagesArray(imagesArray: imagesArray) 37 | 38 | UIGraphicsBeginImageContextWithOptions(totalImageSize,false, 0) 39 | 40 | var imageOffsetFactor:CGFloat = 0 41 | 42 | for img in imagesArray { 43 | img.draw(at: CGPoint(x: 0, y: imageOffsetFactor)) 44 | imageOffsetFactor += img.size.height; 45 | } 46 | unifiedImage = UIGraphicsGetImageFromCurrentImageContext() 47 | UIGraphicsEndImageContext() 48 | return unifiedImage 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Classes/Swift/UIScrollView+Additions.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import UIKit 3 | 4 | extension UIScrollView { 5 | 6 | var screenshotOfVisibleContent : UIImage? { 7 | var croppingRect = self.bounds 8 | croppingRect.origin = self.contentOffset 9 | return self.screenshotForCroppingRect(croppingRect: croppingRect) 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /Classes/Swift/UITableView+Additions.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import UIKit 3 | 4 | extension UITableView { 5 | 6 | override var screenshot : UIImage? { 7 | return self.screenshotExcludingHeadersAtSections(excludedHeaderSections: nil, excludingFootersAtSections:nil, excludingRowsAtIndexPaths:nil) 8 | } 9 | 10 | func screenshotOfCellAtIndexPath(indexPath:NSIndexPath) -> UIImage? { 11 | var cellScreenshot:UIImage? 12 | 13 | let currTableViewOffset = self.contentOffset 14 | 15 | self.scrollToRow(at: indexPath as IndexPath, at: .top, animated: false) 16 | 17 | cellScreenshot = self.cellForRow(at: indexPath as IndexPath)?.screenshot 18 | 19 | self.setContentOffset(currTableViewOffset, animated: false) 20 | 21 | return cellScreenshot; 22 | } 23 | 24 | var screenshotOfHeaderView : UIImage? { 25 | let originalOffset = self.contentOffset 26 | if let headerRect = self.tableHeaderView?.frame { 27 | self.scrollRectToVisible(headerRect, animated: false) 28 | let headerScreenshot = self.screenshotForCroppingRect(croppingRect: headerRect) 29 | self.setContentOffset(originalOffset, animated: false) 30 | 31 | return headerScreenshot; 32 | } 33 | return nil 34 | } 35 | 36 | var screenshotOfFooterView : UIImage? { 37 | let originalOffset = self.contentOffset 38 | if let footerRect = self.tableFooterView?.frame { 39 | self.scrollRectToVisible(footerRect, animated: false) 40 | let footerScreenshot = self.screenshotForCroppingRect(croppingRect: footerRect) 41 | self.setContentOffset(originalOffset, animated: false) 42 | 43 | return footerScreenshot; 44 | } 45 | return nil 46 | } 47 | 48 | func screenshotOfHeaderViewAtSection(section:Int) -> UIImage? { 49 | let originalOffset = self.contentOffset 50 | let headerRect = self.rectForHeader(inSection: section) 51 | 52 | self.scrollRectToVisible(headerRect, animated: false) 53 | let headerScreenshot = self.screenshotForCroppingRect(croppingRect: headerRect) 54 | self.setContentOffset(originalOffset, animated: false) 55 | 56 | return headerScreenshot; 57 | } 58 | 59 | func screenshotOfFooterViewAtSection(section:Int) -> UIImage? { 60 | let originalOffset = self.contentOffset 61 | let footerRect = self.rectForFooter(inSection: section) 62 | 63 | self.scrollRectToVisible(footerRect, animated: false) 64 | let footerScreenshot = self.screenshotForCroppingRect(croppingRect: footerRect) 65 | self.setContentOffset(originalOffset, animated: false) 66 | 67 | return footerScreenshot; 68 | } 69 | 70 | 71 | func screenshotExcludingAllHeaders(withoutHeaders:Bool, excludingAllFooters:Bool, excludingAllRows:Bool) -> UIImage? { 72 | 73 | var excludedHeadersOrFootersSections:[Int]? 74 | 75 | if withoutHeaders || excludingAllFooters { 76 | excludedHeadersOrFootersSections = self.allSectionsIndexes 77 | } 78 | 79 | var excludedRows:[NSIndexPath]? 80 | 81 | if excludingAllRows { 82 | excludedRows = self.allRowsIndexPaths 83 | } 84 | 85 | return self.screenshotExcludingHeadersAtSections( excludedHeaderSections: withoutHeaders ? NSSet(array: excludedHeadersOrFootersSections!) : nil, 86 | excludingFootersAtSections:excludingAllFooters ? NSSet(array:excludedHeadersOrFootersSections!) : nil, excludingRowsAtIndexPaths:excludingAllRows ? NSSet(array:excludedRows!) : nil) 87 | } 88 | 89 | func screenshotExcludingHeadersAtSections(excludedHeaderSections:NSSet?, excludingFootersAtSections:NSSet?, 90 | excludingRowsAtIndexPaths:NSSet?) -> UIImage? { 91 | var screenshots = [UIImage]() 92 | 93 | if let headerScreenshot = self.screenshotOfHeaderView { 94 | screenshots.append(headerScreenshot) 95 | } 96 | 97 | for section in 0.. UIImage? { 125 | var screenshots = [UIImage]() 126 | 127 | for section in 0.. UIImage? { 147 | if excludedIndexPaths == nil || !excludedIndexPaths!.contains(indexPath) { 148 | return nil 149 | } 150 | return self.screenshotOfCellAtIndexPath(indexPath: indexPath) 151 | } 152 | 153 | func screenshotOfHeaderViewAtSection(section:Int, excludedHeaderSections:NSSet?) -> UIImage? { 154 | if excludedHeaderSections != nil && !excludedHeaderSections!.contains(section) { 155 | return nil 156 | } 157 | 158 | var sectionScreenshot = self.screenshotOfHeaderViewAtSection(section: section) 159 | if sectionScreenshot == nil { 160 | sectionScreenshot = self.blankScreenshotOfHeaderAtSection(section: section) 161 | } 162 | return sectionScreenshot; 163 | } 164 | 165 | func screenshotOfFooterViewAtSection(section:Int, excludedFooterSections:NSSet?) -> UIImage? { 166 | if excludedFooterSections != nil && !excludedFooterSections!.contains(section) { 167 | return nil 168 | } 169 | 170 | var sectionScreenshot = self.screenshotOfFooterViewAtSection(section: section) 171 | if sectionScreenshot == nil { 172 | sectionScreenshot = self.blankScreenshotOfFooterAtSection(section: section) 173 | } 174 | return sectionScreenshot; 175 | } 176 | 177 | func screenshotOfCellAtIndexPath(indexPath:NSIndexPath, includedIndexPaths:NSSet?) -> UIImage? { 178 | if includedIndexPaths != nil && !includedIndexPaths!.contains(indexPath) { 179 | return nil 180 | } 181 | return self.screenshotOfCellAtIndexPath(indexPath: indexPath) 182 | } 183 | 184 | func screenshotOfHeaderViewAtSection(section:Int, includedHeaderSections:NSSet?) -> UIImage? { 185 | if includedHeaderSections != nil && !includedHeaderSections!.contains(section) { 186 | return nil 187 | } 188 | 189 | var sectionScreenshot = self.screenshotOfHeaderViewAtSection(section: section) 190 | if sectionScreenshot == nil { 191 | sectionScreenshot = self.blankScreenshotOfHeaderAtSection(section: section) 192 | } 193 | return sectionScreenshot; 194 | } 195 | 196 | func screenshotOfFooterViewAtSection(section:Int, includedFooterSections:NSSet?) 197 | -> UIImage? { 198 | if includedFooterSections != nil && !includedFooterSections!.contains(section) { 199 | return nil 200 | } 201 | var sectionScreenshot = self.screenshotOfFooterViewAtSection(section: section) 202 | if sectionScreenshot == nil { 203 | sectionScreenshot = self.blankScreenshotOfFooterAtSection(section: section) 204 | } 205 | return sectionScreenshot; 206 | } 207 | 208 | func blankScreenshotOfHeaderAtSection(section:Int) -> UIImage? { 209 | 210 | let headerRectSize = CGSize(width: self.bounds.size.width, height: self.rectForHeader(inSection: section).size.height) 211 | 212 | return UIImage.imageWithColor(color: UIColor.clear, size:headerRectSize) 213 | } 214 | 215 | func blankScreenshotOfFooterAtSection(section:Int) -> UIImage? { 216 | let footerRectSize = CGSize(width: self.bounds.size.width, height: self.rectForFooter(inSection: section).size.height) 217 | return UIImage.imageWithColor(color: UIColor.clear, size:footerRectSize) 218 | } 219 | 220 | var allSectionsIndexes : [Int] 221 | { 222 | let numSections = self.numberOfSections 223 | 224 | var allSectionsIndexes = [Int]() 225 | 226 | for section in 0.. UIImage? { 6 | 7 | UIGraphicsBeginImageContextWithOptions(croppingRect.size, false, UIScreen.main.scale); 8 | 9 | let context = UIGraphicsGetCurrentContext() 10 | if context == nil { 11 | return nil; 12 | } 13 | 14 | context!.translateBy(x: -croppingRect.origin.x, y: -croppingRect.origin.y) 15 | self.layoutIfNeeded() 16 | self.layer.render(in: context!) 17 | 18 | let screenshotImage = UIGraphicsGetImageFromCurrentImageContext() 19 | UIGraphicsEndImageContext() 20 | return screenshotImage 21 | } 22 | 23 | var screenshot : UIImage? { 24 | return self.screenshotForCroppingRect(croppingRect: self.bounds) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Classes/UIImage+DHImageAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+ImageFromArrayUtils.h 3 | // TableViewScreenshots 4 | // 5 | // Created by Hernandez Alvarez, David on 11/28/13. 6 | // Copyright (c) 2013 David Hernandez. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIImage (DHImageUtils) 12 | 13 | + (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size; 14 | 15 | @end 16 | 17 | @interface UIImage (DHImageFromArrayUtils) 18 | 19 | + (UIImage *)verticalImageFromArray:(NSArray *)imagesArray; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /Classes/UIImage+DHImageAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+ImageFromArrayUtils.m 3 | // TableViewScreenshots 4 | // 5 | // Created by Hernandez Alvarez, David on 11/28/13. 6 | // Copyright (c) 2013 David Hernandez. All rights reserved. 7 | // 8 | 9 | #import "UIImage+DHImageAdditions.h" 10 | 11 | @implementation UIImage (DHImageUtils) 12 | 13 | + (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size 14 | { 15 | UIGraphicsBeginImageContextWithOptions(size, NO, [UIScreen mainScreen].scale); 16 | CGContextRef context = UIGraphicsGetCurrentContext(); 17 | if (context == NULL) return nil; 18 | 19 | [color set]; 20 | CGContextFillRect(context, CGRectMake(0.f, 0.f, size.width, size.height)); 21 | 22 | UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 23 | UIGraphicsEndImageContext(); 24 | return image; 25 | } 26 | 27 | @end 28 | 29 | @implementation UIImage (DHImageFromArrayUtils) 30 | 31 | + (UIImage *)verticalImageFromArray:(NSArray *)imagesArray 32 | { 33 | UIImage *unifiedImage = nil; 34 | CGSize totalImageSize = [self verticalAppendedTotalImageSizeFromImagesArray:imagesArray]; 35 | UIGraphicsBeginImageContextWithOptions(totalImageSize, NO, 0.f); 36 | // For each image found in the array, create a new big image vertically 37 | CGFloat imageOffsetFactor = 0.0f; 38 | for (UIImage *img in imagesArray) { 39 | [img drawAtPoint:CGPointMake(0, imageOffsetFactor)]; 40 | imageOffsetFactor += img.size.height; 41 | } 42 | 43 | unifiedImage = UIGraphicsGetImageFromCurrentImageContext(); 44 | UIGraphicsEndImageContext(); 45 | return unifiedImage; 46 | } 47 | 48 | + (CGSize)verticalAppendedTotalImageSizeFromImagesArray:(NSArray *)imagesArray 49 | { 50 | CGSize totalSize = CGSizeZero; 51 | for (UIImage *im in imagesArray) { 52 | CGSize imSize = [im size]; 53 | totalSize.height += imSize.height; 54 | // The total width is gonna be always the wider found on the array 55 | totalSize.width = MAX(totalSize.width, imSize.width); 56 | } 57 | return totalSize; 58 | } 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /Classes/UIScrollView+DHSmartScreenshot.h: -------------------------------------------------------------------------------- 1 | // 2 | // UITableView+Screenshot.h 3 | // Kiwi 4 | // 5 | // Created by Marcin Stepnowski on 10/11/14. 6 | // Copyright (c) 2014 Marcin Stepnowski. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIScrollView (DHSmartScreenshot) 12 | 13 | -(UIImage*)screenshotOfVisibleContent; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Classes/UIScrollView+DHSmartScreenshot.m: -------------------------------------------------------------------------------- 1 | // 2 | // UITableView+Screenshot.m 3 | // Kiwi 4 | // 5 | // Created by Marcin Stepnowski on 10/11/14. 6 | // Copyright (c) 2014 Marcin Stepnowski. All rights reserved. 7 | // 8 | 9 | #import "UIScrollView+DHSmartScreenshot.h" 10 | #import "UIView+DHSmartScreenshot.h" 11 | 12 | @implementation UIScrollView (DHSmartScreenshot) 13 | 14 | -(UIImage*)screenshotOfVisibleContent{ 15 | CGRect croppingRect = self.bounds; 16 | croppingRect.origin = self.contentOffset; 17 | return [self screenshotForCroppingRect: croppingRect]; 18 | } 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /Classes/UITableView+DHSmartScreenshot.h: -------------------------------------------------------------------------------- 1 | // 2 | // UITableView+DHSmartScreenshot.h 3 | // TableViewScreenshots 4 | // 5 | // Created by Hernandez Alvarez, David on 11/28/13. 6 | // Copyright (c) 2013 David Hernandez. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UITableView (DHSmartScreenshot) 12 | 13 | - (UIImage *)screenshot; 14 | 15 | - (UIImage *)screenshotOfCellAtIndexPath:(NSIndexPath *)indexPath; 16 | 17 | - (UIImage *)screenshotOfHeaderViewAtSection:(NSUInteger)section; 18 | 19 | - (UIImage *)screenshotOfFooterViewAtSection:(NSUInteger)section; 20 | 21 | - (UIImage *)screenshotExcludingAllHeaders:(BOOL)withoutHeaders 22 | excludingAllFooters:(BOOL)withoutFooters 23 | excludingAllRows:(BOOL)withoutRows; 24 | 25 | - (UIImage *)screenshotExcludingHeadersAtSections:(NSSet *)headerSections 26 | excludingFootersAtSections:(NSSet *)footerSections 27 | excludingRowsAtIndexPaths:(NSSet *)indexPaths; 28 | 29 | - (UIImage *)screenshotOfHeadersAtSections:(NSSet *)headerSections 30 | footersAtSections:(NSSet *)footerSections 31 | rowsAtIndexPaths:(NSSet *)indexPaths; 32 | 33 | @end 34 | 35 | -------------------------------------------------------------------------------- /Classes/UITableView+DHSmartScreenshot.m: -------------------------------------------------------------------------------- 1 | // 2 | // UITableView+DHSmartScreenshot.m 3 | // TableViewScreenshots 4 | // 5 | // Created by Hernandez Alvarez, David on 11/28/13. 6 | // Copyright (c) 2013 David Hernandez. All rights reserved. 7 | // 8 | 9 | #import "UITableView+DHSmartScreenshot.h" 10 | #import "UIView+DHSmartScreenshot.h" 11 | #import "UIImage+DHImageAdditions.h" 12 | 13 | @implementation UITableView (DHSmartScreenshot) 14 | 15 | - (UIImage *)screenshot 16 | { 17 | return [self screenshotExcludingHeadersAtSections:nil 18 | excludingFootersAtSections:nil 19 | excludingRowsAtIndexPaths:nil]; 20 | } 21 | 22 | - (UIImage *)screenshotOfCellAtIndexPath:(NSIndexPath *)indexPath 23 | { 24 | UIImage *cellScreenshot = nil; 25 | 26 | // Current tableview offset 27 | CGPoint currTableViewOffset = self.contentOffset; 28 | 29 | // First, scroll the tableview so the cell would be rendered on the view and able to screenshot'it 30 | [self scrollToRowAtIndexPath:indexPath 31 | atScrollPosition:UITableViewScrollPositionTop 32 | animated:NO]; 33 | 34 | // Take the screenshot 35 | cellScreenshot = [[self cellForRowAtIndexPath:indexPath] screenshot]; 36 | 37 | // scroll back to the original offset 38 | [self setContentOffset:currTableViewOffset animated:NO]; 39 | 40 | return cellScreenshot; 41 | } 42 | 43 | - (UIImage *)screenshotOfHeaderView 44 | { 45 | CGPoint originalOffset = [self contentOffset]; 46 | CGRect headerRect = [self tableHeaderView].frame; 47 | 48 | [self scrollRectToVisible:headerRect animated:NO]; 49 | UIImage *headerScreenshot = [self screenshotForCroppingRect:headerRect]; 50 | [self setContentOffset:originalOffset animated:NO]; 51 | 52 | return headerScreenshot; 53 | } 54 | 55 | - (UIImage *)screenshotOfFooterView 56 | { 57 | CGPoint originalOffset = [self contentOffset]; 58 | CGRect footerRect = [self tableFooterView].frame; 59 | 60 | [self scrollRectToVisible:footerRect animated:NO]; 61 | UIImage *footerScreenshot = [self screenshotForCroppingRect:footerRect]; 62 | [self setContentOffset:originalOffset animated:NO]; 63 | 64 | return footerScreenshot; 65 | } 66 | 67 | - (UIImage *)screenshotOfHeaderViewAtSection:(NSUInteger)section 68 | { 69 | CGPoint originalOffset = [self contentOffset]; 70 | CGRect headerRect = [self rectForHeaderInSection:section]; 71 | 72 | [self scrollRectToVisible:headerRect animated:NO]; 73 | UIImage *headerScreenshot = [self screenshotForCroppingRect:headerRect]; 74 | [self setContentOffset:originalOffset animated:NO]; 75 | 76 | return headerScreenshot; 77 | } 78 | 79 | - (UIImage *)screenshotOfFooterViewAtSection:(NSUInteger)section 80 | { 81 | CGPoint originalOffset = [self contentOffset]; 82 | CGRect footerRect = [self rectForFooterInSection:section]; 83 | 84 | [self scrollRectToVisible:footerRect animated:NO]; 85 | UIImage *footerScreenshot = [self screenshotForCroppingRect:footerRect]; 86 | [self setContentOffset:originalOffset animated:NO]; 87 | 88 | return footerScreenshot; 89 | } 90 | 91 | - (UIImage *)screenshotExcludingAllHeaders:(BOOL)withoutHeaders 92 | excludingAllFooters:(BOOL)withoutFooters 93 | excludingAllRows:(BOOL)withoutRows 94 | { 95 | NSArray *excludedHeadersOrFootersSections = nil; 96 | if (withoutHeaders || withoutFooters) excludedHeadersOrFootersSections = [self allSectionsIndexes]; 97 | 98 | NSArray *excludedRows = nil; 99 | if (withoutRows) excludedRows = [self allRowsIndexPaths]; 100 | 101 | return [self screenshotExcludingHeadersAtSections:(withoutHeaders)?[NSSet setWithArray:excludedHeadersOrFootersSections]:nil 102 | excludingFootersAtSections:(withoutFooters)?[NSSet setWithArray:excludedHeadersOrFootersSections]:nil 103 | excludingRowsAtIndexPaths:(withoutRows)?[NSSet setWithArray:excludedRows]:nil]; 104 | } 105 | 106 | - (UIImage *)screenshotExcludingHeadersAtSections:(NSSet *)excludedHeaderSections 107 | excludingFootersAtSections:(NSSet *)excludedFooterSections 108 | excludingRowsAtIndexPaths:(NSSet *)excludedIndexPaths 109 | { 110 | NSMutableArray *screenshots = [NSMutableArray array]; 111 | // Header Screenshot 112 | UIImage *headerScreenshot = [self screenshotOfHeaderView]; 113 | if (headerScreenshot) [screenshots addObject:headerScreenshot]; 114 | for (int section=0; section 10 | 11 | @interface UIView (DHSmartScreenshot) 12 | 13 | - (UIImage *)screenshot; 14 | - (UIImage *)screenshotForCroppingRect:(CGRect)rect; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Classes/UIView+DHSmartScreenshot.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+DHSmartScreenshot.m 3 | // TableViewScreenshots 4 | // 5 | // Created by Hernandez Alvarez, David on 11/30/13. 6 | // Copyright (c) 2013 David Hernandez. All rights reserved. 7 | // 8 | 9 | #import "UIView+DHSmartScreenshot.h" 10 | 11 | @implementation UIView (DHSmartScreenshot) 12 | 13 | - (UIImage *)screenshot 14 | { 15 | return [self screenshotForCroppingRect:self.bounds]; 16 | } 17 | 18 | - (UIImage *)screenshotForCroppingRect:(CGRect)croppingRect 19 | { 20 | UIGraphicsBeginImageContextWithOptions(croppingRect.size, NO, [UIScreen mainScreen].scale); 21 | // Create a graphics context and translate it the view we want to crop so 22 | // that even in grabbing (0,0), that origin point now represents the actual 23 | // cropping origin desired: 24 | CGContextRef context = UIGraphicsGetCurrentContext(); 25 | if (context == NULL) return nil; 26 | CGContextTranslateCTM(context, -croppingRect.origin.x, -croppingRect.origin.y); 27 | 28 | [self layoutIfNeeded]; 29 | [self.layer renderInContext:context]; 30 | 31 | UIImage *screenshotImage = UIGraphicsGetImageFromCurrentImageContext(); 32 | UIGraphicsEndImageContext(); 33 | return screenshotImage; 34 | } 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /DHSmartScreenshot.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "DHSmartScreenshot" 3 | s.version = "1.3.2" 4 | s.summary = "UITableView/UIScrollView Category to get really easy, smart and instant screenshot images for iOS 5+ devices." 5 | 6 | s.homepage = 'https://github.com/davidman/DHSmartScreenshot' 7 | s.license = { :type => 'MIT'} 8 | s.author = { "David Hernandez" => "dav.viidd94@gmail.com" } 9 | 10 | s.source = { 11 | :git => "https://github.com/davidman/DHSmartScreenshot.git", 12 | :tag => "v#{s.version}" } 13 | 14 | s.platform = :ios 15 | s.source_files = 'Classes/*.{h,m}' 16 | s.requires_arc = true 17 | 18 | s.subspec 'Swift' do |swspec| 19 | swspec.source_files = "Classes/Swift" 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /Example/Storyboard.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | -------------------------------------------------------------------------------- /Example/TableViewScreenshots.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 933F4572184E5D1400953804 /* UIImage+DHImageAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 933F456D184E5D1400953804 /* UIImage+DHImageAdditions.m */; }; 11 | 933F4573184E5D1400953804 /* UITableView+DHSmartScreenshot.m in Sources */ = {isa = PBXBuildFile; fileRef = 933F456F184E5D1400953804 /* UITableView+DHSmartScreenshot.m */; }; 12 | 933F4574184E5D1400953804 /* UIView+DHSmartScreenshot.m in Sources */ = {isa = PBXBuildFile; fileRef = 933F4571184E5D1400953804 /* UIView+DHSmartScreenshot.m */; }; 13 | 93A1C04518481B5300BBB2A6 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 93A1C04418481B5300BBB2A6 /* Foundation.framework */; }; 14 | 93A1C04718481B5300BBB2A6 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 93A1C04618481B5300BBB2A6 /* CoreGraphics.framework */; }; 15 | 93A1C04918481B5300BBB2A6 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 93A1C04818481B5300BBB2A6 /* UIKit.framework */; }; 16 | 93A1C04F18481B5300BBB2A6 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 93A1C04D18481B5300BBB2A6 /* InfoPlist.strings */; }; 17 | 93A1C05118481B5300BBB2A6 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 93A1C05018481B5300BBB2A6 /* main.m */; }; 18 | 93A1C05518481B5300BBB2A6 /* DHAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 93A1C05418481B5300BBB2A6 /* DHAppDelegate.m */; }; 19 | 93A1C05718481B5300BBB2A6 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 93A1C05618481B5300BBB2A6 /* Images.xcassets */; }; 20 | 93A1C05E18481B5300BBB2A6 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 93A1C05D18481B5300BBB2A6 /* XCTest.framework */; }; 21 | 93A1C05F18481B5300BBB2A6 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 93A1C04418481B5300BBB2A6 /* Foundation.framework */; }; 22 | 93A1C06018481B5300BBB2A6 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 93A1C04818481B5300BBB2A6 /* UIKit.framework */; }; 23 | 93A1C06818481B5300BBB2A6 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 93A1C06618481B5300BBB2A6 /* InfoPlist.strings */; }; 24 | 93A1C06A18481B5300BBB2A6 /* TableViewScreenshotsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 93A1C06918481B5300BBB2A6 /* TableViewScreenshotsTests.m */; }; 25 | 93A1C07818481DA500BBB2A6 /* Storyboard.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 93A1C07718481DA500BBB2A6 /* Storyboard.storyboard */; }; 26 | 93A1C07E1848251D00BBB2A6 /* DHMainViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 93A1C07D1848251D00BBB2A6 /* DHMainViewController.m */; }; 27 | 93A1C0811848267500BBB2A6 /* DHScreenshotViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 93A1C0801848267500BBB2A6 /* DHScreenshotViewController.m */; }; 28 | D32BAE271A1B37D800B92E8D /* UIScrollView+DHSmartScreenshot.m in Sources */ = {isa = PBXBuildFile; fileRef = D32BAE261A1B37D800B92E8D /* UIScrollView+DHSmartScreenshot.m */; }; 29 | /* End PBXBuildFile section */ 30 | 31 | /* Begin PBXContainerItemProxy section */ 32 | 93A1C06118481B5300BBB2A6 /* PBXContainerItemProxy */ = { 33 | isa = PBXContainerItemProxy; 34 | containerPortal = 93A1C03918481B5300BBB2A6 /* Project object */; 35 | proxyType = 1; 36 | remoteGlobalIDString = 93A1C04018481B5300BBB2A6; 37 | remoteInfo = TableViewScreenshots; 38 | }; 39 | /* End PBXContainerItemProxy section */ 40 | 41 | /* Begin PBXFileReference section */ 42 | 933F456B184E5D1400953804 /* DHSmartScreenshot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DHSmartScreenshot.h; path = ../Classes/DHSmartScreenshot.h; sourceTree = ""; }; 43 | 933F456C184E5D1400953804 /* UIImage+DHImageAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIImage+DHImageAdditions.h"; path = "../Classes/UIImage+DHImageAdditions.h"; sourceTree = ""; }; 44 | 933F456D184E5D1400953804 /* UIImage+DHImageAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIImage+DHImageAdditions.m"; path = "../Classes/UIImage+DHImageAdditions.m"; sourceTree = ""; }; 45 | 933F456E184E5D1400953804 /* UITableView+DHSmartScreenshot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UITableView+DHSmartScreenshot.h"; path = "../Classes/UITableView+DHSmartScreenshot.h"; sourceTree = ""; }; 46 | 933F456F184E5D1400953804 /* UITableView+DHSmartScreenshot.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UITableView+DHSmartScreenshot.m"; path = "../Classes/UITableView+DHSmartScreenshot.m"; sourceTree = ""; }; 47 | 933F4570184E5D1400953804 /* UIView+DHSmartScreenshot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIView+DHSmartScreenshot.h"; path = "../Classes/UIView+DHSmartScreenshot.h"; sourceTree = ""; }; 48 | 933F4571184E5D1400953804 /* UIView+DHSmartScreenshot.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIView+DHSmartScreenshot.m"; path = "../Classes/UIView+DHSmartScreenshot.m"; sourceTree = ""; }; 49 | 93A1C04118481B5300BBB2A6 /* TableViewScreenshots.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TableViewScreenshots.app; sourceTree = BUILT_PRODUCTS_DIR; }; 50 | 93A1C04418481B5300BBB2A6 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 51 | 93A1C04618481B5300BBB2A6 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 52 | 93A1C04818481B5300BBB2A6 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 53 | 93A1C04C18481B5300BBB2A6 /* TableViewScreenshots-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "TableViewScreenshots-Info.plist"; sourceTree = ""; }; 54 | 93A1C04E18481B5300BBB2A6 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 55 | 93A1C05018481B5300BBB2A6 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 56 | 93A1C05218481B5300BBB2A6 /* TableViewScreenshots-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "TableViewScreenshots-Prefix.pch"; sourceTree = ""; }; 57 | 93A1C05318481B5300BBB2A6 /* DHAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DHAppDelegate.h; sourceTree = ""; }; 58 | 93A1C05418481B5300BBB2A6 /* DHAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DHAppDelegate.m; sourceTree = ""; }; 59 | 93A1C05618481B5300BBB2A6 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 60 | 93A1C05C18481B5300BBB2A6 /* TableViewScreenshotsTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TableViewScreenshotsTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 61 | 93A1C05D18481B5300BBB2A6 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 62 | 93A1C06518481B5300BBB2A6 /* TableViewScreenshotsTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "TableViewScreenshotsTests-Info.plist"; sourceTree = ""; }; 63 | 93A1C06718481B5300BBB2A6 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 64 | 93A1C06918481B5300BBB2A6 /* TableViewScreenshotsTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TableViewScreenshotsTests.m; sourceTree = ""; }; 65 | 93A1C07718481DA500BBB2A6 /* Storyboard.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Storyboard.storyboard; sourceTree = ""; }; 66 | 93A1C07C1848251D00BBB2A6 /* DHMainViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DHMainViewController.h; sourceTree = ""; }; 67 | 93A1C07D1848251D00BBB2A6 /* DHMainViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DHMainViewController.m; sourceTree = ""; }; 68 | 93A1C07F1848267500BBB2A6 /* DHScreenshotViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DHScreenshotViewController.h; sourceTree = ""; }; 69 | 93A1C0801848267500BBB2A6 /* DHScreenshotViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DHScreenshotViewController.m; sourceTree = ""; }; 70 | D32BAE231A1B377C00B92E8D /* UIScrollView+DHSmartScreenshot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIScrollView+DHSmartScreenshot.h"; path = "../Classes/UIScrollView+DHSmartScreenshot.h"; sourceTree = ""; }; 71 | D32BAE261A1B37D800B92E8D /* UIScrollView+DHSmartScreenshot.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIScrollView+DHSmartScreenshot.m"; path = "../Classes/UIScrollView+DHSmartScreenshot.m"; sourceTree = ""; }; 72 | /* End PBXFileReference section */ 73 | 74 | /* Begin PBXFrameworksBuildPhase section */ 75 | 93A1C03E18481B5300BBB2A6 /* Frameworks */ = { 76 | isa = PBXFrameworksBuildPhase; 77 | buildActionMask = 2147483647; 78 | files = ( 79 | 93A1C04718481B5300BBB2A6 /* CoreGraphics.framework in Frameworks */, 80 | 93A1C04918481B5300BBB2A6 /* UIKit.framework in Frameworks */, 81 | 93A1C04518481B5300BBB2A6 /* Foundation.framework in Frameworks */, 82 | ); 83 | runOnlyForDeploymentPostprocessing = 0; 84 | }; 85 | 93A1C05918481B5300BBB2A6 /* Frameworks */ = { 86 | isa = PBXFrameworksBuildPhase; 87 | buildActionMask = 2147483647; 88 | files = ( 89 | 93A1C05E18481B5300BBB2A6 /* XCTest.framework in Frameworks */, 90 | 93A1C06018481B5300BBB2A6 /* UIKit.framework in Frameworks */, 91 | 93A1C05F18481B5300BBB2A6 /* Foundation.framework in Frameworks */, 92 | ); 93 | runOnlyForDeploymentPostprocessing = 0; 94 | }; 95 | /* End PBXFrameworksBuildPhase section */ 96 | 97 | /* Begin PBXGroup section */ 98 | 933F456A184E5CEF00953804 /* DHSmartScreenshot */ = { 99 | isa = PBXGroup; 100 | children = ( 101 | 933F456B184E5D1400953804 /* DHSmartScreenshot.h */, 102 | 933F456C184E5D1400953804 /* UIImage+DHImageAdditions.h */, 103 | 933F456D184E5D1400953804 /* UIImage+DHImageAdditions.m */, 104 | 933F456E184E5D1400953804 /* UITableView+DHSmartScreenshot.h */, 105 | 933F456F184E5D1400953804 /* UITableView+DHSmartScreenshot.m */, 106 | D32BAE231A1B377C00B92E8D /* UIScrollView+DHSmartScreenshot.h */, 107 | D32BAE261A1B37D800B92E8D /* UIScrollView+DHSmartScreenshot.m */, 108 | 933F4570184E5D1400953804 /* UIView+DHSmartScreenshot.h */, 109 | 933F4571184E5D1400953804 /* UIView+DHSmartScreenshot.m */, 110 | ); 111 | name = DHSmartScreenshot; 112 | sourceTree = ""; 113 | }; 114 | 93A1C03818481B5300BBB2A6 = { 115 | isa = PBXGroup; 116 | children = ( 117 | 93A1C07718481DA500BBB2A6 /* Storyboard.storyboard */, 118 | 933F456A184E5CEF00953804 /* DHSmartScreenshot */, 119 | 93A1C04A18481B5300BBB2A6 /* TableViewScreenshots */, 120 | 93A1C06318481B5300BBB2A6 /* TableViewScreenshotsTests */, 121 | 93A1C04318481B5300BBB2A6 /* Frameworks */, 122 | 93A1C04218481B5300BBB2A6 /* Products */, 123 | ); 124 | sourceTree = ""; 125 | }; 126 | 93A1C04218481B5300BBB2A6 /* Products */ = { 127 | isa = PBXGroup; 128 | children = ( 129 | 93A1C04118481B5300BBB2A6 /* TableViewScreenshots.app */, 130 | 93A1C05C18481B5300BBB2A6 /* TableViewScreenshotsTests.xctest */, 131 | ); 132 | name = Products; 133 | sourceTree = ""; 134 | }; 135 | 93A1C04318481B5300BBB2A6 /* Frameworks */ = { 136 | isa = PBXGroup; 137 | children = ( 138 | 93A1C04418481B5300BBB2A6 /* Foundation.framework */, 139 | 93A1C04618481B5300BBB2A6 /* CoreGraphics.framework */, 140 | 93A1C04818481B5300BBB2A6 /* UIKit.framework */, 141 | 93A1C05D18481B5300BBB2A6 /* XCTest.framework */, 142 | ); 143 | name = Frameworks; 144 | sourceTree = ""; 145 | }; 146 | 93A1C04A18481B5300BBB2A6 /* TableViewScreenshots */ = { 147 | isa = PBXGroup; 148 | children = ( 149 | 93A1C05318481B5300BBB2A6 /* DHAppDelegate.h */, 150 | 93A1C05418481B5300BBB2A6 /* DHAppDelegate.m */, 151 | 93A1C07C1848251D00BBB2A6 /* DHMainViewController.h */, 152 | 93A1C07D1848251D00BBB2A6 /* DHMainViewController.m */, 153 | 93A1C07F1848267500BBB2A6 /* DHScreenshotViewController.h */, 154 | 93A1C0801848267500BBB2A6 /* DHScreenshotViewController.m */, 155 | 93A1C05618481B5300BBB2A6 /* Images.xcassets */, 156 | 93A1C04B18481B5300BBB2A6 /* Supporting Files */, 157 | ); 158 | path = TableViewScreenshots; 159 | sourceTree = ""; 160 | }; 161 | 93A1C04B18481B5300BBB2A6 /* Supporting Files */ = { 162 | isa = PBXGroup; 163 | children = ( 164 | 93A1C04C18481B5300BBB2A6 /* TableViewScreenshots-Info.plist */, 165 | 93A1C04D18481B5300BBB2A6 /* InfoPlist.strings */, 166 | 93A1C05018481B5300BBB2A6 /* main.m */, 167 | 93A1C05218481B5300BBB2A6 /* TableViewScreenshots-Prefix.pch */, 168 | ); 169 | name = "Supporting Files"; 170 | sourceTree = ""; 171 | }; 172 | 93A1C06318481B5300BBB2A6 /* TableViewScreenshotsTests */ = { 173 | isa = PBXGroup; 174 | children = ( 175 | 93A1C06918481B5300BBB2A6 /* TableViewScreenshotsTests.m */, 176 | 93A1C06418481B5300BBB2A6 /* Supporting Files */, 177 | ); 178 | path = TableViewScreenshotsTests; 179 | sourceTree = ""; 180 | }; 181 | 93A1C06418481B5300BBB2A6 /* Supporting Files */ = { 182 | isa = PBXGroup; 183 | children = ( 184 | 93A1C06518481B5300BBB2A6 /* TableViewScreenshotsTests-Info.plist */, 185 | 93A1C06618481B5300BBB2A6 /* InfoPlist.strings */, 186 | ); 187 | name = "Supporting Files"; 188 | sourceTree = ""; 189 | }; 190 | /* End PBXGroup section */ 191 | 192 | /* Begin PBXNativeTarget section */ 193 | 93A1C04018481B5300BBB2A6 /* TableViewScreenshots */ = { 194 | isa = PBXNativeTarget; 195 | buildConfigurationList = 93A1C06D18481B5300BBB2A6 /* Build configuration list for PBXNativeTarget "TableViewScreenshots" */; 196 | buildPhases = ( 197 | 93A1C03D18481B5300BBB2A6 /* Sources */, 198 | 93A1C03E18481B5300BBB2A6 /* Frameworks */, 199 | 93A1C03F18481B5300BBB2A6 /* Resources */, 200 | ); 201 | buildRules = ( 202 | ); 203 | dependencies = ( 204 | ); 205 | name = TableViewScreenshots; 206 | productName = TableViewScreenshots; 207 | productReference = 93A1C04118481B5300BBB2A6 /* TableViewScreenshots.app */; 208 | productType = "com.apple.product-type.application"; 209 | }; 210 | 93A1C05B18481B5300BBB2A6 /* TableViewScreenshotsTests */ = { 211 | isa = PBXNativeTarget; 212 | buildConfigurationList = 93A1C07018481B5300BBB2A6 /* Build configuration list for PBXNativeTarget "TableViewScreenshotsTests" */; 213 | buildPhases = ( 214 | 93A1C05818481B5300BBB2A6 /* Sources */, 215 | 93A1C05918481B5300BBB2A6 /* Frameworks */, 216 | 93A1C05A18481B5300BBB2A6 /* Resources */, 217 | ); 218 | buildRules = ( 219 | ); 220 | dependencies = ( 221 | 93A1C06218481B5300BBB2A6 /* PBXTargetDependency */, 222 | ); 223 | name = TableViewScreenshotsTests; 224 | productName = TableViewScreenshotsTests; 225 | productReference = 93A1C05C18481B5300BBB2A6 /* TableViewScreenshotsTests.xctest */; 226 | productType = "com.apple.product-type.bundle.unit-test"; 227 | }; 228 | /* End PBXNativeTarget section */ 229 | 230 | /* Begin PBXProject section */ 231 | 93A1C03918481B5300BBB2A6 /* Project object */ = { 232 | isa = PBXProject; 233 | attributes = { 234 | CLASSPREFIX = DH; 235 | LastUpgradeCheck = 0500; 236 | ORGANIZATIONNAME = "David Hernandez"; 237 | TargetAttributes = { 238 | 93A1C05B18481B5300BBB2A6 = { 239 | TestTargetID = 93A1C04018481B5300BBB2A6; 240 | }; 241 | }; 242 | }; 243 | buildConfigurationList = 93A1C03C18481B5300BBB2A6 /* Build configuration list for PBXProject "TableViewScreenshots" */; 244 | compatibilityVersion = "Xcode 3.2"; 245 | developmentRegion = English; 246 | hasScannedForEncodings = 0; 247 | knownRegions = ( 248 | en, 249 | ); 250 | mainGroup = 93A1C03818481B5300BBB2A6; 251 | productRefGroup = 93A1C04218481B5300BBB2A6 /* Products */; 252 | projectDirPath = ""; 253 | projectRoot = ""; 254 | targets = ( 255 | 93A1C04018481B5300BBB2A6 /* TableViewScreenshots */, 256 | 93A1C05B18481B5300BBB2A6 /* TableViewScreenshotsTests */, 257 | ); 258 | }; 259 | /* End PBXProject section */ 260 | 261 | /* Begin PBXResourcesBuildPhase section */ 262 | 93A1C03F18481B5300BBB2A6 /* Resources */ = { 263 | isa = PBXResourcesBuildPhase; 264 | buildActionMask = 2147483647; 265 | files = ( 266 | 93A1C04F18481B5300BBB2A6 /* InfoPlist.strings in Resources */, 267 | 93A1C05718481B5300BBB2A6 /* Images.xcassets in Resources */, 268 | 93A1C07818481DA500BBB2A6 /* Storyboard.storyboard in Resources */, 269 | ); 270 | runOnlyForDeploymentPostprocessing = 0; 271 | }; 272 | 93A1C05A18481B5300BBB2A6 /* Resources */ = { 273 | isa = PBXResourcesBuildPhase; 274 | buildActionMask = 2147483647; 275 | files = ( 276 | 93A1C06818481B5300BBB2A6 /* InfoPlist.strings in Resources */, 277 | ); 278 | runOnlyForDeploymentPostprocessing = 0; 279 | }; 280 | /* End PBXResourcesBuildPhase section */ 281 | 282 | /* Begin PBXSourcesBuildPhase section */ 283 | 93A1C03D18481B5300BBB2A6 /* Sources */ = { 284 | isa = PBXSourcesBuildPhase; 285 | buildActionMask = 2147483647; 286 | files = ( 287 | D32BAE271A1B37D800B92E8D /* UIScrollView+DHSmartScreenshot.m in Sources */, 288 | 93A1C0811848267500BBB2A6 /* DHScreenshotViewController.m in Sources */, 289 | 93A1C05518481B5300BBB2A6 /* DHAppDelegate.m in Sources */, 290 | 93A1C05118481B5300BBB2A6 /* main.m in Sources */, 291 | 933F4572184E5D1400953804 /* UIImage+DHImageAdditions.m in Sources */, 292 | 93A1C07E1848251D00BBB2A6 /* DHMainViewController.m in Sources */, 293 | 933F4574184E5D1400953804 /* UIView+DHSmartScreenshot.m in Sources */, 294 | 933F4573184E5D1400953804 /* UITableView+DHSmartScreenshot.m in Sources */, 295 | ); 296 | runOnlyForDeploymentPostprocessing = 0; 297 | }; 298 | 93A1C05818481B5300BBB2A6 /* Sources */ = { 299 | isa = PBXSourcesBuildPhase; 300 | buildActionMask = 2147483647; 301 | files = ( 302 | 93A1C06A18481B5300BBB2A6 /* TableViewScreenshotsTests.m in Sources */, 303 | ); 304 | runOnlyForDeploymentPostprocessing = 0; 305 | }; 306 | /* End PBXSourcesBuildPhase section */ 307 | 308 | /* Begin PBXTargetDependency section */ 309 | 93A1C06218481B5300BBB2A6 /* PBXTargetDependency */ = { 310 | isa = PBXTargetDependency; 311 | target = 93A1C04018481B5300BBB2A6 /* TableViewScreenshots */; 312 | targetProxy = 93A1C06118481B5300BBB2A6 /* PBXContainerItemProxy */; 313 | }; 314 | /* End PBXTargetDependency section */ 315 | 316 | /* Begin PBXVariantGroup section */ 317 | 93A1C04D18481B5300BBB2A6 /* InfoPlist.strings */ = { 318 | isa = PBXVariantGroup; 319 | children = ( 320 | 93A1C04E18481B5300BBB2A6 /* en */, 321 | ); 322 | name = InfoPlist.strings; 323 | sourceTree = ""; 324 | }; 325 | 93A1C06618481B5300BBB2A6 /* InfoPlist.strings */ = { 326 | isa = PBXVariantGroup; 327 | children = ( 328 | 93A1C06718481B5300BBB2A6 /* en */, 329 | ); 330 | name = InfoPlist.strings; 331 | sourceTree = ""; 332 | }; 333 | /* End PBXVariantGroup section */ 334 | 335 | /* Begin XCBuildConfiguration section */ 336 | 93A1C06B18481B5300BBB2A6 /* Debug */ = { 337 | isa = XCBuildConfiguration; 338 | buildSettings = { 339 | ALWAYS_SEARCH_USER_PATHS = NO; 340 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 341 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 342 | CLANG_CXX_LIBRARY = "libc++"; 343 | CLANG_ENABLE_MODULES = YES; 344 | CLANG_ENABLE_OBJC_ARC = YES; 345 | CLANG_WARN_BOOL_CONVERSION = YES; 346 | CLANG_WARN_CONSTANT_CONVERSION = YES; 347 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 348 | CLANG_WARN_EMPTY_BODY = YES; 349 | CLANG_WARN_ENUM_CONVERSION = YES; 350 | CLANG_WARN_INT_CONVERSION = YES; 351 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 352 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 353 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 354 | COPY_PHASE_STRIP = NO; 355 | GCC_C_LANGUAGE_STANDARD = gnu99; 356 | GCC_DYNAMIC_NO_PIC = NO; 357 | GCC_OPTIMIZATION_LEVEL = 0; 358 | GCC_PREPROCESSOR_DEFINITIONS = ( 359 | "DEBUG=1", 360 | "$(inherited)", 361 | ); 362 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 363 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 364 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 365 | GCC_WARN_UNDECLARED_SELECTOR = YES; 366 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 367 | GCC_WARN_UNUSED_FUNCTION = YES; 368 | GCC_WARN_UNUSED_VARIABLE = YES; 369 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 370 | ONLY_ACTIVE_ARCH = YES; 371 | SDKROOT = iphoneos; 372 | TARGETED_DEVICE_FAMILY = "1,2"; 373 | }; 374 | name = Debug; 375 | }; 376 | 93A1C06C18481B5300BBB2A6 /* Release */ = { 377 | isa = XCBuildConfiguration; 378 | buildSettings = { 379 | ALWAYS_SEARCH_USER_PATHS = NO; 380 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 381 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 382 | CLANG_CXX_LIBRARY = "libc++"; 383 | CLANG_ENABLE_MODULES = YES; 384 | CLANG_ENABLE_OBJC_ARC = YES; 385 | CLANG_WARN_BOOL_CONVERSION = YES; 386 | CLANG_WARN_CONSTANT_CONVERSION = YES; 387 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 388 | CLANG_WARN_EMPTY_BODY = YES; 389 | CLANG_WARN_ENUM_CONVERSION = YES; 390 | CLANG_WARN_INT_CONVERSION = YES; 391 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 392 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 393 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 394 | COPY_PHASE_STRIP = YES; 395 | ENABLE_NS_ASSERTIONS = NO; 396 | GCC_C_LANGUAGE_STANDARD = gnu99; 397 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 398 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 399 | GCC_WARN_UNDECLARED_SELECTOR = YES; 400 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 401 | GCC_WARN_UNUSED_FUNCTION = YES; 402 | GCC_WARN_UNUSED_VARIABLE = YES; 403 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 404 | SDKROOT = iphoneos; 405 | TARGETED_DEVICE_FAMILY = "1,2"; 406 | VALIDATE_PRODUCT = YES; 407 | }; 408 | name = Release; 409 | }; 410 | 93A1C06E18481B5300BBB2A6 /* Debug */ = { 411 | isa = XCBuildConfiguration; 412 | buildSettings = { 413 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 414 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 415 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 416 | GCC_PREFIX_HEADER = "TableViewScreenshots/TableViewScreenshots-Prefix.pch"; 417 | INFOPLIST_FILE = "TableViewScreenshots/TableViewScreenshots-Info.plist"; 418 | PRODUCT_NAME = "$(TARGET_NAME)"; 419 | WRAPPER_EXTENSION = app; 420 | }; 421 | name = Debug; 422 | }; 423 | 93A1C06F18481B5300BBB2A6 /* Release */ = { 424 | isa = XCBuildConfiguration; 425 | buildSettings = { 426 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 427 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 428 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 429 | GCC_PREFIX_HEADER = "TableViewScreenshots/TableViewScreenshots-Prefix.pch"; 430 | INFOPLIST_FILE = "TableViewScreenshots/TableViewScreenshots-Info.plist"; 431 | PRODUCT_NAME = "$(TARGET_NAME)"; 432 | WRAPPER_EXTENSION = app; 433 | }; 434 | name = Release; 435 | }; 436 | 93A1C07118481B5300BBB2A6 /* Debug */ = { 437 | isa = XCBuildConfiguration; 438 | buildSettings = { 439 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 440 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/TableViewScreenshots.app/TableViewScreenshots"; 441 | FRAMEWORK_SEARCH_PATHS = ( 442 | "$(SDKROOT)/Developer/Library/Frameworks", 443 | "$(inherited)", 444 | "$(DEVELOPER_FRAMEWORKS_DIR)", 445 | ); 446 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 447 | GCC_PREFIX_HEADER = "TableViewScreenshots/TableViewScreenshots-Prefix.pch"; 448 | GCC_PREPROCESSOR_DEFINITIONS = ( 449 | "DEBUG=1", 450 | "$(inherited)", 451 | ); 452 | INFOPLIST_FILE = "TableViewScreenshotsTests/TableViewScreenshotsTests-Info.plist"; 453 | PRODUCT_NAME = "$(TARGET_NAME)"; 454 | TEST_HOST = "$(BUNDLE_LOADER)"; 455 | WRAPPER_EXTENSION = xctest; 456 | }; 457 | name = Debug; 458 | }; 459 | 93A1C07218481B5300BBB2A6 /* Release */ = { 460 | isa = XCBuildConfiguration; 461 | buildSettings = { 462 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 463 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/TableViewScreenshots.app/TableViewScreenshots"; 464 | FRAMEWORK_SEARCH_PATHS = ( 465 | "$(SDKROOT)/Developer/Library/Frameworks", 466 | "$(inherited)", 467 | "$(DEVELOPER_FRAMEWORKS_DIR)", 468 | ); 469 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 470 | GCC_PREFIX_HEADER = "TableViewScreenshots/TableViewScreenshots-Prefix.pch"; 471 | INFOPLIST_FILE = "TableViewScreenshotsTests/TableViewScreenshotsTests-Info.plist"; 472 | PRODUCT_NAME = "$(TARGET_NAME)"; 473 | TEST_HOST = "$(BUNDLE_LOADER)"; 474 | WRAPPER_EXTENSION = xctest; 475 | }; 476 | name = Release; 477 | }; 478 | /* End XCBuildConfiguration section */ 479 | 480 | /* Begin XCConfigurationList section */ 481 | 93A1C03C18481B5300BBB2A6 /* Build configuration list for PBXProject "TableViewScreenshots" */ = { 482 | isa = XCConfigurationList; 483 | buildConfigurations = ( 484 | 93A1C06B18481B5300BBB2A6 /* Debug */, 485 | 93A1C06C18481B5300BBB2A6 /* Release */, 486 | ); 487 | defaultConfigurationIsVisible = 0; 488 | defaultConfigurationName = Release; 489 | }; 490 | 93A1C06D18481B5300BBB2A6 /* Build configuration list for PBXNativeTarget "TableViewScreenshots" */ = { 491 | isa = XCConfigurationList; 492 | buildConfigurations = ( 493 | 93A1C06E18481B5300BBB2A6 /* Debug */, 494 | 93A1C06F18481B5300BBB2A6 /* Release */, 495 | ); 496 | defaultConfigurationIsVisible = 0; 497 | defaultConfigurationName = Release; 498 | }; 499 | 93A1C07018481B5300BBB2A6 /* Build configuration list for PBXNativeTarget "TableViewScreenshotsTests" */ = { 500 | isa = XCConfigurationList; 501 | buildConfigurations = ( 502 | 93A1C07118481B5300BBB2A6 /* Debug */, 503 | 93A1C07218481B5300BBB2A6 /* Release */, 504 | ); 505 | defaultConfigurationIsVisible = 0; 506 | defaultConfigurationName = Release; 507 | }; 508 | /* End XCConfigurationList section */ 509 | }; 510 | rootObject = 93A1C03918481B5300BBB2A6 /* Project object */; 511 | } 512 | -------------------------------------------------------------------------------- /Example/TableViewScreenshots.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/TableViewScreenshots/DHAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // DHAppDelegate.h 3 | // TableViewScreenshots 4 | // 5 | // Created by Hernandez Alvarez, David on 11/28/13. 6 | // Copyright (c) 2013 David Hernandez. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DHAppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Example/TableViewScreenshots/DHAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // DHAppDelegate.m 3 | // TableViewScreenshots 4 | // 5 | // Created by Hernandez Alvarez, David on 11/28/13. 6 | // Copyright (c) 2013 David Hernandez. All rights reserved. 7 | // 8 | 9 | #import "DHAppDelegate.h" 10 | 11 | @implementation DHAppDelegate 12 | 13 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 14 | { 15 | return YES; 16 | } 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Example/TableViewScreenshots/DHMainViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // DHMainViewController.h 3 | // TableViewScreenshots 4 | // 5 | // Created by Hernandez Alvarez, David on 11/28/13. 6 | // Copyright (c) 2013 David Hernandez. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DHMainViewController : UITableViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Example/TableViewScreenshots/DHMainViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // DHMainViewController.m 3 | // TableViewScreenshots 4 | // 5 | // Created by Hernandez Alvarez, David on 11/28/13. 6 | // Copyright (c) 2013 David Hernandez. All rights reserved. 7 | // 8 | 9 | #import "DHMainViewController.h" 10 | #import "DHSmartScreenshot.h" 11 | 12 | @interface DHMainViewController () 13 | @property (strong, nonatomic) UIImage *screenshotTaken; 14 | @end 15 | 16 | @implementation DHMainViewController 17 | 18 | - (void)viewDidLoad 19 | { 20 | [super viewDidLoad]; 21 | 22 | // Uncomment the following line to preserve selection between presentations. 23 | self.clearsSelectionOnViewWillAppear = YES; 24 | } 25 | 26 | - (void)viewDidAppear:(BOOL)animated 27 | { 28 | [super viewDidAppear:animated]; 29 | self.screenshotTaken = nil; 30 | } 31 | 32 | - (void)didReceiveMemoryWarning 33 | { 34 | [super didReceiveMemoryWarning]; 35 | // Dispose of any resources that can be recreated. 36 | } 37 | 38 | #pragma mark - Take Screenshot Examples 39 | 40 | - (void)takeFullScreenshot 41 | { 42 | self.screenshotTaken = [self.tableView screenshot]; 43 | } 44 | 45 | - (void)takeScreenshotWithoutHeaders 46 | { 47 | self.screenshotTaken = [self.tableView screenshotExcludingAllHeaders:YES 48 | excludingAllFooters:NO 49 | excludingAllRows:NO]; 50 | } 51 | 52 | - (void)takeScreenshotWithoutFooters 53 | { 54 | self.screenshotTaken = [self.tableView screenshotExcludingAllHeaders:NO 55 | excludingAllFooters:YES 56 | excludingAllRows:NO]; 57 | } 58 | 59 | - (void)takeScreenshotForRowsOnly 60 | { 61 | self.screenshotTaken = [self.tableView screenshotExcludingAllHeaders:YES 62 | excludingAllFooters:YES 63 | excludingAllRows:NO]; 64 | } 65 | 66 | - (void)takeScreenshotForRowAtIndexPath:(NSIndexPath *)indexPath 67 | { 68 | self.screenshotTaken = [self.tableView screenshotOfCellAtIndexPath:indexPath]; 69 | } 70 | 71 | -(void)takeScreenshotOfVisibleContent{ 72 | self.screenshotTaken = [self.tableView screenshotOfVisibleContent]; 73 | } 74 | 75 | - (void)takeScreenshotWithoutFirstHeader 76 | { 77 | NSArray *excludedHeadersSections = @[@(0)]; 78 | self.screenshotTaken = [self.tableView screenshotExcludingHeadersAtSections:[NSSet setWithArray:excludedHeadersSections] 79 | excludingFootersAtSections:nil 80 | excludingRowsAtIndexPaths:nil]; 81 | } 82 | 83 | - (void)takeScreenshoOfJustLastTwoFooters 84 | { 85 | NSArray *includeFootersSections = @[@(self.tableView.numberOfSections - 2), @(self.tableView.numberOfSections - 1)]; 86 | self.screenshotTaken = [self.tableView screenshotOfHeadersAtSections:nil 87 | footersAtSections:[NSSet setWithArray:includeFootersSections] rowsAtIndexPaths:nil]; 88 | } 89 | 90 | - (void)takeScreenshotForJustRowsOnThisSection:(NSUInteger)section 91 | { 92 | NSArray *includedRows = nil; 93 | includedRows = [self.tableView indexPathsForRowsInRect:[self.tableView rectForSection:section]]; 94 | self.screenshotTaken = [self.tableView screenshotOfHeadersAtSections:nil 95 | footersAtSections:nil 96 | rowsAtIndexPaths:[NSSet setWithArray:includedRows]]; 97 | } 98 | 99 | - (void)takeScreenshotForComplexUse 100 | { 101 | NSMutableArray *includedRows = [NSMutableArray array]; 102 | [includedRows addObject:[NSIndexPath indexPathForRow:0 inSection:0]]; 103 | [includedRows addObject:[NSIndexPath indexPathForRow:0 inSection:1]]; 104 | [includedRows addObject:[NSIndexPath indexPathForRow:0 inSection:2]]; 105 | 106 | NSMutableArray *includedHeadersSections = [NSMutableArray array]; 107 | [includedHeadersSections addObject:@(0)]; 108 | [includedHeadersSections addObject:@(1)]; 109 | [includedHeadersSections addObject:@(3)]; 110 | 111 | NSMutableArray *includedFootersSections = [NSMutableArray array]; 112 | [includedFootersSections addObject:@(0)]; 113 | [includedFootersSections addObject:@(1)]; 114 | [includedFootersSections addObject:@(2)]; 115 | [includedFootersSections addObject:@(4)]; 116 | 117 | self.screenshotTaken = [self.tableView screenshotOfHeadersAtSections:[NSSet setWithArray:includedHeadersSections] 118 | footersAtSections:[NSSet setWithArray:includedFootersSections] 119 | rowsAtIndexPaths:[NSSet setWithArray:includedRows]]; 120 | } 121 | 122 | #pragma mark - TableView Delegate 123 | 124 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 125 | { 126 | if (indexPath.section == 0) { 127 | if (indexPath.row == 0) { 128 | [self takeFullScreenshot]; 129 | } else if (indexPath.row == 1) { 130 | [self takeScreenshotWithoutHeaders]; 131 | } else if (indexPath.row == 2) { 132 | [self takeScreenshotWithoutFooters]; 133 | } else if (indexPath.row == 3) { 134 | [self takeScreenshotForRowsOnly]; 135 | } else if (indexPath.row == 4) { 136 | [self takeScreenshotForRowAtIndexPath:indexPath]; 137 | } else if (indexPath.row == 5) { 138 | [self takeScreenshotOfVisibleContent]; 139 | } 140 | } else if (indexPath.section == 1) { 141 | if (indexPath.row == 0) { 142 | [self takeScreenshotWithoutFirstHeader]; 143 | } else if (indexPath.row == 1) { 144 | [self takeScreenshoOfJustLastTwoFooters]; 145 | } else if (indexPath.row == 2) { 146 | [self takeScreenshotForJustRowsOnThisSection:indexPath.section]; 147 | } 148 | } else if (indexPath.section == 2) { 149 | [self takeScreenshotForComplexUse]; 150 | } else { 151 | [self takeFullScreenshot]; 152 | } 153 | [self performSegueWithIdentifier:@"showTableViewScreenshotSegue_Id" sender:self]; 154 | } 155 | 156 | #pragma mark - Navigation 157 | 158 | // In a story board-based application, you will often want to do a little preparation before navigation 159 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 160 | { 161 | if ([[segue identifier] isEqualToString:@"showTableViewScreenshotSegue_Id"]) { 162 | UIViewController *destination = [segue destinationViewController]; 163 | [destination setValue:self.screenshotTaken forKey:@"screenshot"]; 164 | } 165 | } 166 | 167 | @end 168 | -------------------------------------------------------------------------------- /Example/TableViewScreenshots/DHScreenshotViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // DHScreenshotViewController.h 3 | // TableViewScreenshots 4 | // 5 | // Created by Hernandez Alvarez, David on 11/28/13. 6 | // Copyright (c) 2013 David Hernandez. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DHScreenshotViewController : UIViewController 12 | 13 | @property (strong, nonatomic) UIImage *screenshot; 14 | 15 | - (IBAction)shareButtonPressed:(id)sender; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Example/TableViewScreenshots/DHScreenshotViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // DHScreenshotViewController.m 3 | // TableViewScreenshots 4 | // 5 | // Created by Hernandez Alvarez, David on 11/28/13. 6 | // Copyright (c) 2013 David Hernandez. All rights reserved. 7 | // 8 | 9 | #import "DHScreenshotViewController.h" 10 | 11 | @interface DHScreenshotViewController () 12 | @property (strong, nonatomic) IBOutlet UIScrollView *scrollView; 13 | @property (strong, nonatomic) UIImageView *screenshotImageView; 14 | @end 15 | 16 | @implementation DHScreenshotViewController 17 | 18 | - (void)viewWillAppear:(BOOL)animated 19 | { 20 | [super viewWillAppear:animated]; 21 | 22 | self.screenshotImageView = [[UIImageView alloc] initWithImage:self.screenshot]; 23 | [self.screenshotImageView setBackgroundColor:[UIColor whiteColor]]; 24 | [self.scrollView addSubview:self.screenshotImageView]; 25 | [self.scrollView setContentSize:self.screenshotImageView.bounds.size]; 26 | [self.scrollView setMinimumZoomScale:1.f]; 27 | [self.scrollView setMaximumZoomScale:3.f]; 28 | [self.scrollView setDelegate:self]; 29 | } 30 | 31 | #pragma mark - ScrollView Delegate 32 | 33 | - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView 34 | { 35 | return self.screenshotImageView; 36 | } 37 | 38 | #pragma mark - Share Button Action 39 | 40 | - (IBAction)shareButtonPressed:(id)sender 41 | { 42 | UIActivityViewController *activityController = nil; 43 | activityController = [[UIActivityViewController alloc] initWithActivityItems:@[self.screenshot] 44 | applicationActivities:nil]; 45 | [self presentViewController:activityController animated:YES completion:nil]; 46 | } 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /Example/TableViewScreenshots/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "40x40", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "60x60", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "ipad", 20 | "size" : "29x29", 21 | "scale" : "1x" 22 | }, 23 | { 24 | "idiom" : "ipad", 25 | "size" : "29x29", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "ipad", 30 | "size" : "40x40", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "40x40", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "76x76", 41 | "scale" : "1x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "76x76", 46 | "scale" : "2x" 47 | } 48 | ], 49 | "info" : { 50 | "version" : 1, 51 | "author" : "xcode" 52 | } 53 | } -------------------------------------------------------------------------------- /Example/TableViewScreenshots/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "7.0", 8 | "scale" : "2x" 9 | }, 10 | { 11 | "orientation" : "portrait", 12 | "idiom" : "iphone", 13 | "subtype" : "retina4", 14 | "extent" : "full-screen", 15 | "minimum-system-version" : "7.0", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "orientation" : "portrait", 20 | "idiom" : "ipad", 21 | "extent" : "full-screen", 22 | "minimum-system-version" : "7.0", 23 | "scale" : "1x" 24 | }, 25 | { 26 | "orientation" : "landscape", 27 | "idiom" : "ipad", 28 | "extent" : "full-screen", 29 | "minimum-system-version" : "7.0", 30 | "scale" : "1x" 31 | }, 32 | { 33 | "orientation" : "portrait", 34 | "idiom" : "ipad", 35 | "extent" : "full-screen", 36 | "minimum-system-version" : "7.0", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "orientation" : "landscape", 41 | "idiom" : "ipad", 42 | "extent" : "full-screen", 43 | "minimum-system-version" : "7.0", 44 | "scale" : "2x" 45 | } 46 | ], 47 | "info" : { 48 | "version" : 1, 49 | "author" : "xcode" 50 | } 51 | } -------------------------------------------------------------------------------- /Example/TableViewScreenshots/TableViewScreenshots-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | com.davidhernandez.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | UIMainStoryboardFile 28 | Storyboard 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /Example/TableViewScreenshots/TableViewScreenshots-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #import 8 | 9 | #ifndef __IPHONE_3_0 10 | #warning "This project uses features only available in iOS SDK 3.0 and later." 11 | #endif 12 | 13 | #ifdef __OBJC__ 14 | #import 15 | #import 16 | #endif 17 | -------------------------------------------------------------------------------- /Example/TableViewScreenshots/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Example/TableViewScreenshots/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // TableViewScreenshots 4 | // 5 | // Created by Hernandez Alvarez, David on 11/28/13. 6 | // Copyright (c) 2013 David Hernandez. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "DHAppDelegate.h" 12 | 13 | int main(int argc, char * argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([DHAppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Example/TableViewScreenshotsTests/TableViewScreenshotsTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.davidhernandez.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Example/TableViewScreenshotsTests/TableViewScreenshotsTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // TableViewScreenshotsTests.m 3 | // TableViewScreenshotsTests 4 | // 5 | // Created by Hernandez Alvarez, David on 11/28/13. 6 | // Copyright (c) 2013 David Hernandez. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface TableViewScreenshotsTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation TableViewScreenshotsTests 16 | 17 | - (void)setUp 18 | { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown 24 | { 25 | // Put teardown code here. This method is called after the invocation of each test method in the class. 26 | [super tearDown]; 27 | } 28 | 29 | - (void)testExample 30 | { 31 | XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__); 32 | } 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /Example/TableViewScreenshotsTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 David Hernandez 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | DHSmartScreenshot 2 | ================= 3 | 4 | UITableView/UIScrollView Category to get really easy, smart and instant screenshot images like no other library out there for iOS 5+ devices. 5 | 6 | 7 | Screenshots 8 | ----------- 9 | 10 | This is a tableview on the simulator: 11 | 12 | ![iOS TableView on Simulator](http://i.imgur.com/oIZJ5bT.png) 13 | 14 | And here is the full screenshot image that you get by selecting the first row (full screenshot image): 15 | 16 | ![Screenshot Taken - Example](http://i.imgur.com/w6UkZCD.png) 17 | 18 | 19 | Installation 20 | ------------ 21 | 22 | 1. The preferred way of installation is via [CocoaPods](http://cocoapods.org). Just add 23 | 24 | ```ruby 25 | pod 'DHSmartScreenshot' 26 | ``` 27 | 28 | to your Podfile and run `pod install`. It will install the most recent version of DHSmartScreenshot. 29 | 30 | Alternatively you could copy all the files in the ```Classes/``` directory into your project. Be sure 'Copy items to destination group's folder' is checked. 31 | 32 | 33 | Usage 34 | ----- 35 | 36 | 1. Import the header: ```#import "DHSmartScreenshot.h"``` 37 | 38 | 2. Call 39 | ```objective-c 40 | UIImage * tableViewScreenshot = [self.tableView screenshot]; 41 | ``` 42 | to get a full screenshot of your tableView instance or see below to know what method to call and get a custom screenshot that better fits your needs. 43 | 44 | 45 | Methods 46 | ------- 47 | 48 | There are some methods to customize the way you want to take the screenshot. 49 | Each one of them is self descriptive and works as you could expect, take a look: 50 | 51 | ```objective-c 52 | - (UIImage *)screenshot; 53 | ``` 54 | 55 | ```objective-c 56 | - (UIImage *)screenshotOfCellAtIndexPath:(NSIndexPath *)indexPath; 57 | ``` 58 | 59 | ```objective-c 60 | - (UIImage *)screenshotOfHeaderViewAtSection:(NSUInteger)section; 61 | ``` 62 | 63 | ```objective-c 64 | - (UIImage *)screenshotOfFooterViewAtSection:(NSUInteger)section; 65 | ``` 66 | 67 | ```objective-c 68 | - (UIImage *)screenshotExcludingAllHeaders:(BOOL)withoutHeaders 69 | excludingAllFooters:(BOOL)withoutFooters 70 | excludingAllRows:(BOOL)withoutRows; 71 | ``` 72 | 73 | ```objective-c 74 | - (UIImage *)screenshotExcludingHeadersAtSections:(NSSet *)headerSections 75 | excludingFootersAtSections:(NSSet *)footerSections 76 | excludingRowsAtIndexPaths:(NSSet *)indexPaths; 77 | ``` 78 | 79 | ```objective-c 80 | - (UIImage *)screenshotOfHeadersAtSections:(NSSet *)headerSections 81 | footersAtSections:(NSSet *)footerSections 82 | rowsAtIndexPaths:(NSSet *)indexPaths; 83 | ``` 84 | 85 | ```objective-c 86 | - (UIImage *)screenshotOfVisibleContent; 87 | ``` 88 | 89 | Contribution 90 | ------------ 91 | 92 | Sure :) please send a pull-request or raise an issue. It is always good to know how to make things better, yay! 93 | 94 | 95 | Author 96 | ------ 97 | 98 | David Hernandez ([dav.viidd94@gmail.com](mailto:dav.viidd94@gmail.com)) 99 | 100 | 101 | License 102 | ------- 103 | 104 | DHSmartScreenshot is under the MIT License. 105 | --------------------------------------------------------------------------------