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 }