Re: [問題] UIView特定範圍截圖

看板MacDev作者 (白毛)時間11年前 (2013/10/18 17:17), 編輯推噓1(105)
留言6則, 3人參與, 最新討論串3/5 (看更多)
本來想把這個方法用在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

10/18 17:22, , 1F
不在可視範圍內的cell不會被畫(render)出來 看起來很難達成
10/18 17:22, 1F

10/19 19:41, , 2F
UIGraphics...WithOptions(tableview.contentSize, 1, 0);
10/19 19:41, 2F

10/19 19:42, , 3F
設定contentOffest = CGPointZero , tableview的height為
10/19 19:42, 3F

10/19 19:43, , 4F
contentSize.height 這樣試試
10/19 19:43, 4F

10/21 13:23, , 5F
經過測試可以截取可視範圍外的cell
10/21 13:23, 5F

10/22 09:56, , 6F
你的意思是說 改變tableView的size嗎?
10/22 09:56, 6F
文章代碼(AID): #1IOFoTAT (MacDev)
討論串 (同標題文章)
文章代碼(AID): #1IOFoTAT (MacDev)