OC裁剪图片

-(UIImage *)clipImageWithImage:(UIImage * )image isLeftImage:(BOOL)isLeft{

CGRect imageRect = CGRectMake(0, 0, image.size.width/2, image.size.height);

if (!isLeft) {

imageRect.origin.x = image.size.width/2;

}

CGImageRef  imgRef = CGImageCreateWithImageInRect(image.CGImage, imageRect);

UIImage * clipImage = [UIImage imageWithCGImage:imgRef];

CGImageRelease(imgRef);

return clipImage;

}

你可能感兴趣的:(OC裁剪图片)