我现在使用如下方法对屏幕截图:UIGraphicsBeginImageContext(self.view.bounds.size);[self.view.layerrenderInContext:UIGraphicsGetCurrentContext()];currentCaptureImage=UIGraphicsGetImageFromCurrentImageContext();UIGraphicsEndImageContext();但我想要的是区域截图,也就是说,我要设置origin坐标,然后设置width和height,请问怎么做?
2 回答
潇湘沐
TA贡献1816条经验 获得超6个赞
CGRectrect=self.view.frame;UIGraphicsBeginImageContext(rect.size);CGContextRefcontext=UIGraphicsGetCurrentContext();[self.view.layerrenderInContext:context];UIImage*img=UIGraphicsGetImageFromCurrentImageContext();UIGraphicsEndImageContext();floatoriginX;floatoriginy;floatwidth;floatheight;//你需要的区域起点,宽,高;CGRectrect1=CGRectMake(originX,originY,width,height);UIImage*imgeee=[UIImageimageWithCGImage:CGImageCreateWithImageInRect([imgCGImage],rect1)];
添加回答
举报
0/150
提交
取消