UIImage的缩放问题

来源:互联网 发布:出国打工软件 编辑:程序博客网 时间:2024/05/17 04:13

#pragma mark - 完成图片的缩放

- (UIImage*)imageWithImageSimple:(UIImage*)image scaledToSize:(CGSize)newSize

{

    // Create a graphics image context

    UIGraphicsBeginImageContext(newSize);

    // Tell the old image to draw in this new context, with the desired

    // 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 the new image.

    return newImage;

}

0 0