1 - (UIImage *)CutImageWithImage:(UIImage *)image withRect:(CGRect)rect 2 { 3 //使用CGImageCreateWithImageInRect方法切割图片,第一个参数为CGImage类型,第二个参数为要切割的CGRect 4 CGImageRef cutImage = CGImageCreateWithImageInRect(image.CGImage, rect); 5 //将切割出得图片转换为UIImage 6 UIImage *resultImage = [UIImage imageWithCGImage:cutImage]; 7 return resultImage; 8 }