UIGraphics内存泄漏

时间:2013-05-29 06:54:10

标签: ios objective-c uigraphicscontext

- (UIImage *)deleteBackgroundOfImage:(UIImageView *)image
{
    CGRect rect = CGRectZero;
    rect.size = image.image.size;

    UIGraphicsBeginImageContextWithOptions(rect.size, YES, 0.0);

    UIImage *mask = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    UIGraphicsBeginImageContextWithOptions(rect.size, NO, 0.0);

    {
        CGContextClipToMask(UIGraphicsGetCurrentContext(), rect, mask.CGImage);
        [image.image drawAtPoint:CGPointZero];
    }

    UIImage *maskedImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return maskedImage;
}

当我将上述功能调用两次时,我收到了“收到内存警告”,任何人都可以告诉我泄漏的位置。谢谢提前。

0 个答案:

没有答案