亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

我想要的是區域截圖,我要設置origin坐標,然后設置width和height,請問怎么做?

我想要的是區域截圖,我要設置origin坐標,然后設置width和height,請問怎么做?

iOS
躍然一笑 2023-04-26 19:15:35
我現在使用如下方法對屏幕截圖: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)];


查看完整回答
反對 回復 2023-04-29
?
PIPIONE

TA貢獻1829條經驗 獲得超9個贊

主要就是下面這句

UIImage *resultImg = [UIImage imageWithCGImage:CGImageCreateWithImageInRect(img.CGImage, rect)];


查看完整回答
反對 回復 2023-04-29
  • 2 回答
  • 0 關注
  • 331 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號