我有泄漏,我看不到哪里。
这是我的代码的一部分:
+ (UIImage *) imageWithColor:(UIColor *) color andSize:(CGSize) size {
UIGraphicsBeginImageContext(size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, color.CGColor);
CGContextFillRect(context, CGRectMake(0, 0, size.width, size.height));
UIImage *colorImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return colorImage;
}
然后我使用返回的 UIImage 作为 UIProgressView 的跟踪和进度图像
UIImage* trackImage = [ImageUtils imageWithColor:[UIColor blackColor] andSize:CGSizeMake(self.myProgressView.frame.size.width, 3)];
UIImage* progressImage = [ImageUtils imageWithColor:[UIColor whiteColor] andSize:CGSizeMake(self.myProgressView.frame.size.width, 3)];
[self.myProgressView setTrackImage:trackImage];
[self.myProgressView setProgressImage:progressImage];
但是,不知何故,在我释放包含进度视图的对象后,这会导致指向 UIGraphicsGetImageFromCurrentImageContext 的泄漏。我该如何解决?