iOS ——屏幕截图

func screenShot(targetView : UIView) -> UIImage{

    

        UIGraphicsBeginImageContextWithOptions(targetView.bounds.size, false, 0)

        targetView.drawViewHierarchyInRect(targetView.bounds, afterScreenUpdates: false)

        

        let snapdImage = UIGraphicsGetImageFromCurrentImageContext()

        UIGraphicsEndImageContext()

        return snapdImage!

    }

原文地址:https://www.cnblogs.com/madarax/p/6170548.html