Hello,
I have a custom UIButton with a png inside it. I have quite a few of them in my app and everywhere they seem to be working fine.
In one location they are inside a UIView that is a headerView for a UITableview.
Whenever I press on them, only on iPhone 2G the image box goes black while the rest of the UIButton (it's got a title...) looks fine. After you go out of the view controller and come back the "pressed" image shows fine.
Any ideas why? My images are compressed inside the app file.
Thanks!
UPDATE #1: I used some code that someone graciously offered here on stackoverflow that generates an image from a backcolor so you could put it to use via backgroundImage property. I use it and that seems to be causing the problem. Everytime I press my button it takes my image used and renders a black box instead of it while it displayed the image generated correctly.
- (UIImage *)imageWithColor:(UIColor *)color {
CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}