作者whitefur (白毛)
看板MacDev
标题Re: [问题] UIView特定范围截图
时间Fri Oct 18 17:17:14 2013
本来想把这个方法用在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
1F:推 ahchie:不在可视范围内的cell不会被画(render)出来 看起来很难达成 10/18 17:22
2F:→ yuanruo:UIGraphics...WithOptions(tableview.contentSize, 1, 0); 10/19 19:41
3F:→ yuanruo:设定contentOffest = CGPointZero , tableview的height为 10/19 19:42
4F:→ yuanruo:contentSize.height 这样试试 10/19 19:43
5F:→ yuanruo:经过测试可以截取可视范围外的cell 10/21 13:23
6F:→ whitefur:你的意思是说 改变tableView的size吗? 10/22 09:56