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