I have a leak and I can't see where.
This is part of my code:
+ (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;
}
and then I use the returned UIImage as the track and progress images of a 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];
But, somehow, after I released the object containing the Progress View, this causes a leak pointing to UIGraphicsGetImageFromCurrentImageContext. How can I fix it?