iOS 切割图片

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 }

 

转载于:https://www.cnblogs.com/pretty-guy/p/4027156.html

你可能感兴趣的:(移动开发)