Ami*_*sar 6

-(UIImage*)scaleToSize:(CGSize)size image:(UIImage*)image
{
    UIGraphicsBeginImageContext(size);

    // Draw the scaled image in the current context
    [image drawInRect:CGRectMake(0, 0, size.width, size.height)];

    // Create a new image from current context
    UIImage* scaledImage = UIGraphicsGetImageFromCurrentImageContext();

    // Pop the current context from the stack
    UIGraphicsEndImageContext();

    // Return our new scaled image
    return scaledImage;
}
Run Code Online (Sandbox Code Playgroud)