使用UIImage+YYAdd.h的:
- (UIImage *)imageByResizeToSize:(CGSize)size { if (size.width <= 0 || size.height <= 0) return nil; UIGraphicsBeginImageContextWithOptions(size, NO, self.scale); [self drawInRect:CGRectMake(0, 0, size.width, size.height)]; UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return image; }