Snap

179 阅读1分钟
func snapshotWithView(view:UIView)  -> UIImage? {
    let size = view.bounds.size;
    UIGraphicsBeginImageContextWithOptions(size, true, 0);
    view.drawHierarchy(in: view.bounds, afterScreenUpdates: true)
    let image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return image;

}