這是我的代碼,在我的應用程序中拍攝部分屏幕截圖!屏幕截圖的大小正是我想要的,但是當我在相機膠捲中拉起它時,圖像看起來並不重要,而不是我想要的質量。我寫的代碼有什麼問題?爲什麼我的部分屏幕快照模糊不清?
@IBAction func screenShotButton(sender: Any Object) {
let top: CGFloat = 196
let bottom: CGFloat = 197
let size = CGSize(width: view.frame.size.width, height: view.frame.size.height - top - bottom)
UIGraphicsBeginImageContext(size)
let context = UIGraphicsGetCurrentContext()!
CGContextTranslateCTM(context, 0, -top)
view.layer.renderInContext(context)
let snapshot = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
UIImageWriteToSavedPhotosAlbum(snapshot, nil, nil, nil)
}
你能告訴我們一個模糊截圖的例子嗎? – mech