Skip to content

Instantly share code, notes, and snippets.

@jrturton
Created March 14, 2016 01:12
Show Gist options
  • Save jrturton/76d71410d6dc7a643def to your computer and use it in GitHub Desktop.
Save jrturton/76d71410d6dc7a643def to your computer and use it in GitHub Desktop.
import UIKit
// Snapshot utilities
extension UIView {
func snapshotView(view: UIView, afterUpdates: Bool) -> UIView {
let snapshot = view.snapshotViewAfterScreenUpdates(afterUpdates)
self.addSubview(snapshot)
snapshot.frame = convertRect(view.bounds, fromView: view)
return snapshot
}
func snapshotViews(views: [UIView], afterUpdates: Bool) -> [UIView] {
return views.map { snapshotView($0, afterUpdates: afterUpdates) }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment