My first question here:) Recently I update my Xcode to 8, and the resizableSnapshotView
method doesn\'t work properly on some simulators. The snapshotView works we
Works in:
Swift 3
import Foundation
import UIKit
extension UIView {
func snapshotView() -> UIView? {
guard let image = snapshotImage() else { return nil }
return UIImageView(image: image)
}
func snapshotImage() -> UIImage? {
UIGraphicsBeginImageContextWithOptions(bounds.size, isOpaque, contentScaleFactor)
defer { UIGraphicsEndImageContext() }
drawHierarchy(in: bounds, afterScreenUpdates: false)
return UIGraphicsGetImageFromCurrentImageContext()
}
}