swift - 画图截取图片

1.
    func test(addView:UIView) -> UIImage?{
        UIGraphicsBeginImageContextWithOptions(CGSize(width: JY_DEVICE_WIDTH, height: addView.height), false, UIScreen.main.scale)
        
        if let context = UIGraphicsGetCurrentContext() {
            addView.layer.render(in: context)
            let imamge = UIGraphicsGetImageFromCurrentImageContext()
            UIGraphicsEndImageContext()
            return imamge
        }
        return nil
    }

  

猜你喜欢

转载自www.cnblogs.com/qingzZ/p/9914697.html