Swiftpack.co - YK-Unit/SnapshotKit as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by YK-Unit.
YK-Unit/SnapshotKit 0.3.2
UIView/UIWindow/UIScrollView/UITableView/UIWebView/WKWebView Extension to easily take snapshot image of visible or full content.
⭐️ 133
🕓 2 years ago
iOS
.package(url: "https://github.com/YK-Unit/SnapshotKit.git", from: "0.3.2")

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.

GitHub

link
Stars: 133
Last commit: 2 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics