Re: [問題] UIView特定範圍截圖
※ 引述《whitefur (白毛)》之銘言:
: 想在UIView上特定區城的做截圖
: 目前找到最接近的方法只能截出左上角
: 假設要截取左上角長寬200的區城
: UIGraphicsBeginImageContextWithOptions(CGSizeMake(200, 200), self.view.opaque, self.view.contentScaleFactor);
: CGContextRef context = UIGraphicsGetCurrentContext();
: [self.view.layer renderInContext:context];
: UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
: UIGraphicsEndImageContext();
: 請問該如何截出左上角以外的特定區城呢?
: 感謝
還差一步就可以做到 利用CGImageRef
CGRect rect = CGRectMake( 你想要的rect );
CGImageRef imageRef = \
CGImageCreateWithImageInRect([上面截的UIImage CGImage], rect);
UIImage* croppedImage = [UIImage imageWithCGImage:imageRef
scale:1.0f
orientation:對應的UIImageOrientation];
CGImageRelease(imageRef);
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 1.34.186.156
推
10/18 13:15, , 1F
10/18 13:15, 1F
→
10/18 13:49, , 2F
10/18 13:49, 2F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 5 篇):
MacDev 近期熱門文章
PTT數位生活區 即時熱門文章