- (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;
}
当我两次调用上述函数时,我得到“收到内存警告”,任何人都可以告诉我泄漏的位置。提前谢谢。