我试图获得截图,但是我的结果图像有点模糊。我该如何解决它并使其更加清晰?为什么我用Swift获得屏幕截图模糊?
let window = UIApplication.sharedApplication().delegate!.window!!
UIGraphicsBeginImageContextWithOptions(CGSize(width: UIScreen.mainScreen().bounds.width, height: UIScreen.mainScreen().bounds.height - 80), true, UIScreen.mainScreen().scale)
window.drawViewHierarchyInRect(window.bounds, afterScreenUpdates: true)
let windowImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
UIGraphicsBeginImageContext(CGSize(width: UIScreen.mainScreen().bounds.width, height: UIScreen.mainScreen().bounds.height - 145))
windowImage.drawAtPoint(CGPoint(x: -0, y: -65))
let croppedImage: UIImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(croppedImage, nil, nil, nil)
这是我的代码
@dasblinkenlight,但我已经设置了我自己的决议。没有? –
@dasblinkenlight我甚至将刻度设置为'0.0' –
@dasblinkenlight不,我没有。但在'0'的情况下,它将等于'0'。这就是为什么在我的问题,我采取了screen.scale。为什么你问过它? –