Swift 将view转化为图像

 

将view 转换成图像

 //    将某个view 转换成图像
    class func getImageFromView(view:UIView) ->UIImage{
     
        UIGraphicsBeginImageContext(view.bounds.size)

        view.layer.render(in: UIGraphicsGetCurrentContext()!)

        let image = UIGraphicsGetImageFromCurrentImageContext()

        UIGraphicsEndImageContext()

        return image!

    }

 

posted @ 2017-11-07 22:11  小炮陈  阅读(2712)  评论(0编辑  收藏  举报