Re: [問題] UIView特定範圍截圖

看板MacDev作者 (啵B勸-福.加油)時間11年前 (2013/10/18 13:08), 編輯推噓1(101)
留言2則, 2人參與, 最新討論串2/5 (看更多)
※ 引述《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
我剛已經修文了, 看來你跟我同時回文XD
10/18 13:15, 1F

10/18 13:49, , 2F
哈哈 水喔 (Y)
10/18 13:49, 2F
文章代碼(AID): #1IOC9Go- (MacDev)
文章代碼(AID): #1IOC9Go- (MacDev)