我现在使用如下方法对屏幕截图:UIGraphicsBeginImageContext(self.view.bounds.size);[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];currentCaptureImage = UIGraphicsGetImageFromCurrentImageContext();UIGraphicsEndImageContext();
2 回答
汪汪一只猫
TA贡献1898条经验 获得超8个赞
CGRect rect =self.view.frame;
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[self.view.layer renderInContext:context];
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
float originX ;
float originy ;
float width ;
float height ;
//你需要的区域起点,宽,高;
CGRect rect1 = CGRectMake(originX , originY , width , height);
UIImage * imgeee = [UIImage imageWithCGImage:CGImageCreateWithImageInRect([img CGImage], rect1)];
PIPIONE
TA贡献1829条经验 获得超9个赞
主要就是下面这句
UIImage *resultImg = [UIImage imageWithCGImage:CGImageCreateWithImageInRect(img.CGImage, rect)];
- 2 回答
- 0 关注
- 260 浏览
添加回答
举报
0/150
提交
取消