UIImage 剪裁的方法

UIImage 剪裁的方法   转自:http://iphone.xiaoxiaostudio.net/2013/04/10/uiimage-%E5%89%AA%E8%A3%81%E7%9A%84%E6%96%B9%E6%B3%95/

 

 

在UIImage上扩展一个函数

 

@interface UIImage (Resize)

- (UIImage *)croppedImage:(CGRect)bounds;

@end

 

@implementation UIImage (Resize)

 

// Returns a copy of this image that is cropped to the given bounds.

// The bounds will be adjusted using CGRectIntegral.

// This method ignores the image’s imageOrientation setting.

- (UIImage *)croppedImage:(CGRect)bounds {

CGImageRef imageRef = CGImageCreateWithImageInRect([self CGImage], bounds);

UIImage *croppedImage = [UIImage imageWithCGImage:imageRef];

CGImageRelease(imageRef);

return croppedImage;

}

@end

posted @ 2013-04-25 09:48  松花江以南  阅读(273)  评论(0编辑  收藏  举报