看板 MacDev 關於我們 聯絡資訊
本來想把這個方法用在tableView上面 結果好像沒辦法 請問該怎麼截取連續的cells (cells的個數不限 所以有可能超出螢幕 例如:截取一整個section的cells) : 想在UIView上特定區城的做截圖 : : UIGraphicsBeginImageContextWithOptions(CGSizeMake(200, 200), self.view.opaque, self.view.contentScaleFactor); : CGContextRef context = UIGraphicsGetCurrentContext(); : [self.view.layer renderInContext:context]; : UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); : UIGraphicsEndImageContext(); : : 自問自答 : : 把上面的第一行改成UIView的size : : UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, : self.view.opaque, : self.view.contentScaleFactor); : 先把UIView轉成UIImage : 最後再用CGImageCreateWithImageInRect截圖 : CGImageRef shotImageRef = CGImageCreateWithImageInRect(image.CGImage, : CGRectMake(200, 200, 100, 100)); -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 1.160.26.73
ahchie:不在可視範圍內的cell不會被畫(render)出來 看起來很難達成 10/18 17:22
yuanruo:UIGraphics...WithOptions(tableview.contentSize, 1, 0); 10/19 19:41
yuanruo:設定contentOffest = CGPointZero , tableview的height為 10/19 19:42
yuanruo:contentSize.height 這樣試試 10/19 19:43
yuanruo:經過測試可以截取可視範圍外的cell 10/21 13:23
whitefur:你的意思是說 改變tableView的size嗎? 10/22 09:56