SwViewCapture: 一個用起來還不錯的iOS截圖庫

jopen 8年前發布 | 20K 次閱讀 iOS開發 移動開發

SwViewCapture

A nice iOS View Capture Library which can capture all content.

SwViewCapture could convert all content of UIWebView to a UIImage.

一個用起來還不錯的iOS截圖庫.(支持截取所有內容, 適用于所有ScrollView組成的視圖, 包括WebView)

SwViewCapture支持截取網頁以及ScrollView的所有內容

Example

Feature

  1. API is more easy to use.
    • use swift extension
  2. Support to capture all content of scrollView.
    • eg: UIScrollView, UITableView, UIWebView
  3. Support capture WKWebView.
    • WKWebview is hard to capture;
    • Screenshots of WKWebview's content isn't good now
  4. Flasing will not appear in the process of Screenshots.
    • SwCaptureView use a fake screenshots as a cover which over target view. All the action of target will be hidden below the fake screenshots.

功能

  1. API更容易使用.

    • 使用Extension去封裝API
  2. 支持截取滾動視圖內的所有內容.

    • 支持UIScrollView, UITableView, UIWebView
  3. 支持截取WKWebView的內容.

    • 因為WKWebView的內部實現問題, WKWebView比較難去截屏
    • 目前SwViewCapture對WKWebView的截屏也不完美, 還存在一些瑕疵, 尤其表現在CSS樣式為dispaly: absolute;的元素上。
  4. 截圖過程中不會出現視圖閃爍.

    • 截圖過程中, 使用一張偽裝截圖遮蓋屏幕, 底層截圖活動不透明化。

Usage

  1. Capture basic screenshots (size of view's frame)
import SwViewCapture
// ...
view.swCapture { (capturedImage) -> Void in
    // capturedImage is a UIImage.           
}
  1. Capture all content screenshots (size of content)
import SwViewCapture
// ...
view.swContentCapture { (capturedImage) -> Void in
    // capturedImage is a UIImage.           
}

用法

  1. 普通截屏(屏幕大小)
import SwViewCapture // ... view.swCapture { (capturedImage) -> Void in     // capturedImage is a UIImage.            }
  1. 內容截屏(全部內容的大小)
import SwViewCapture // ... view.swContentCapture { (capturedImage) -> Void in     // capturedImage is a UIImage.            }

Requirement

iOS 8.0+, Swift 2.0+

SwViewCapture is available through CocoaPods now. To Install it, simply and the following line to your Podfile:

pod "SwViewCapture"

License

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

項目地址: https://github.com/startry/SwViewCapture

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!