OC 中從圖片上截圖一部分內(nèi)容
//截取部分圖片并生成新圖片
CGImageRef sourceImageRef = [image CGImage];
CGImageRef newImageRef = CGImageCreateWithImageInRect(sourceImageRef, dianRect);
UIImage *newImage = [UIImage imageWithCGImage:newImageRef scale:[UIScreen mainScreen].scale orientation:UIImageOrientationUp];
Swift 中從圖片上截圖一部分內(nèi)容
let sourceImageRef: CGImageRef = image.CGImage!
let newCGImage = CGImageCreateWithImageInRect(sourceImageRef, CGRectMake(0, 0, image.size.width, imageViewHeight))!
let newImage = UIImage.init(CGImage: newCGImage)
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者