我已经实现了把一个UIView直接生成图片。
UIGraphicsBeginImageContext(myView.bounds.size); [myView.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();
但是,我需要截取这个UIView的一部分,比如中间100个像素,怎么实现呢?
这个地方不是已经获取到当前图像的context了么,然后用路径裁剪获取需要的部分应该就可以吧。
不知道可以么,没有试。