views:

283

answers:

1

I have a UIToolbar where I have dragged a UIButton. When I set the button properties to Custom, and assign an image (or background image) the graphics don't appear. However, when I give it a custom text, the text will appear. Why is it that the images don't appear?

A: 

Are you sure the image is present in your bundle/project?

Are you setting the button's image for UIControlStateNormal?

Shaggy Frog
Yes to both. Interesting, when I use a separate image, it appears fine. I'm wondering if something is wrong with the image that I'm using?
Sheehan Alam
Can you display that image in a `UIImageView`? Have you tried a clean build to ensure all the resources are being correctly bundled?
Shaggy Frog
Yes, that image does load in UIImageView and even in a normal photo editor. Build cleaned.
Sheehan Alam
Is the button's alpha set to 0? Is it set to be opaque? Is it the same with all images or just one image?
Shaggy Frog
Could be the image? I tried it with another image and it showed up fine...
Sheehan Alam
Initialize the `UIImage` object separately (before the call to `setImage:forState:`) and make sure it's not `nil` for some reason.
Shaggy Frog