/SnapshotKit

UIView/UIWindow/UIScrollView/UITableView/UIWebView/WKWebView Extension to easily take snapshot image of visible or full content.

Primary LanguageSwiftMIT LicenseMIT

SnapshotKit

Version License Platform

A Kit that can make UIView/UIWindow/UIScrollView/UITableView/UIWebView/WKWebView to easily take snapshot image of visible or full content.

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

UIView Example

func uiView_takeSnapshotOfVisibleContent() {
    let image = self.view.takeSnapshotOfVisibleContent()
    // edit image 
}

func uiView_sync_takeSnapshotOfFullContent() {
    let image = self.view.takeSnapshotOfFullContent()
    // edit image 
}

func uiView_async_takeSnapshotOfFullContent() {
    self.view.asyncTakeSnapshotOfFullContent { (image) in
      // edit image 
    }
}

UIScrollView Example

private func takeSnapshotOfVisibleContent() {
    let image = self.scrollView.takeSnapshotOfVisibleContent()
    // edit image
}

private func sync_takeSnapshotOfFullContent() {
    let image = self.scrollView.takeSnapshotOfFullContent()
    // edit image
}

private func async_takeSnapshotOfFullContent() {
    self.scrollView.asyncTakeSnapshotOfFullContent { (image) in
      // edit image
    }
}

UITableView Example

func uiTableView_takeSnapshotOfVisibleContent() {
    let image = self.tableView.takeSnapshotOfVisibleContent()
    // edit image
}

func uiTableView_sync_takeSnapshotOfFullContent() {
    let image = self.tableView.takeSnapshotOfFullContent()
    // edit image
}

func uiTableView_async_takeSnapshotOfFullContent() {
    self.tableView.asyncTakeSnapshotOfFullContent { (image) in
      // edit image
    }
}

WKWebView Example

private func takeSnapshotOfVisibleContent() {
    let image = self.webView.takeSnapshotOfVisibleContent()
    // edit image
}

private func sync_takeSnapshotOfFullContent() {
    let image = self.webView.takeSnapshotOfFullContent()
    // edit image
}

private func async_takeSnapshotOfFullContent_bySpliter() {
    self.webView.scrollView.asyncTakeSnapshotOfFullContent { (image) in
      // edit image
    }
}

private func async_takeSnapshotOfFullContent_byPrinter() {
    self.webView.asyncTakeSnapshotOfFullContent { (image) in
      // edit image
    }
}

Installation

SnapshotKit is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'SnapshotKit'

License

SnapshotKit is available under the MIT license. See the LICENSE file for more info.