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
Use the following UIView extension to create a snapshot using CoreGraphics.
I can confirm this works on iPhone 7 simulator.
public extension UIView {
public func snapshotImage() -> UIImage? {
UIGraphicsBeginImageContextWithOptions(bounds.size, isOpaque, 0)
drawHierarchy(in: bounds, afterScreenUpdates: false)
let snapshotImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return snapshotImage
}
public func snapshotView() -> UIView? {
if let snapshotImage = snapshotImage() {
return UIImageView(image: snapshotImage)
} else {
return nil
}
}
}