iOS--图片缩放

转自:http://mazhibao2010.blog.163.com/blog/static/182512674201311463750457/

/*
 缩放图片,将图片缩放为指定尺寸大小
 */
- (UIImage*)imageWithImageSimple:(UIImage*)image scaledToSize:(CGSize)newSize
{
    // Create a graphics image context
    UIGraphicsBeginImageContext(newSize);
    
    [image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
    UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return newImage;
}

调用  
 img = [self imageWithImageSimple:img scaledToSize:CGSizeMake(200, 200)];


你可能感兴趣的:(iOS--图片缩放)