2
在我的iOS應用程序中,我採取了UIImageView的屏幕截圖。如附件照片所示,它非常完美。但在這裏,我已採取UIImageView content mode
方面適合。我已經使用這個代碼。截圖UIImageView我只需要圖像IOS
func captureView() -> UIImage {
UIGraphicsBeginImageContextWithOptions(imageView.bounds.size, false,UIScreen.mainScreen().scale)//add this line
let context: CGContextRef = UIGraphicsGetCurrentContext()!
self.backView.layer.renderInContext(context)
let img: UIImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return img
}
我只需要Image的快照,而不是ImageView。幫我介紹一下。
嘗試[此](http://stackoverflow.com/a/6284498/790842)來獲得圖像的確切大小和尺寸提供給代碼當你製作截圖時,儘管你也需要調整frame.x。 – iphonic
獲取圖像視圖的圖像,'imageView.image' – zylenv
@zylenv沒有試圖讓那種容易的事情 – JAck