我試圖獲得截圖,但是我的結果圖像有點模糊。我該如何解決它並使其更加清晰?爲什麼我用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。爲什麼你問過它? –