看板 MacDev 關於我們 聯絡資訊
※ 引述《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
whitefur:我剛已經修文了, 看來你跟我同時回文XD 10/18 13:15
ahchie:哈哈 水喔 (Y) 10/18 13:49