我正在研究
IOS应用程序,其中需要采取清晰的屏幕截图我已经尝试过了
func captureView() -> UIImage {
//hide controls if needed
let rect: CGRect = self.imageView.frame
UIGraphicsBeginImageContext(rect.size)
let context: CGContextRef = UIGraphicsGetCurrentContext()!
self.view.layer.renderInContext(context)
let img: UIImage = UIGraphicsGetimageFromCurrentimageContext()
UIGraphicsEndImageContext()
return img
}
但是图像的质量并不好.请为我推荐一些东西.
解决方法
换线
UIGraphicsBeginImageContext(rect.size)
至
UIGraphicsBeginImageContextWithOptions(rect.size,false,0.0);