Objective C: Resize image

+ (UIImage*)resizeImageWithImage:(UIImage*)image toSize:(CGSize)newSize
{
    // Create a graphics image context
    UIGraphicsBeginImageContext(newSize);
 
    // draw in new context, with the new size
    [image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)];
 
    // Get the new image from the context
    UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
 
    // End the context
    UIGraphicsEndImageContext();
 
    return newImage;
}

2 comments:

  1. This worked great! I used it to resize images into thumbnails for a table view.

    Thanks!
    Jeff

    ReplyDelete
  2. how can i resize multiple image through array

    ReplyDelete