I have an image that I want to display on a UIBarButtonItem, but for some reason it only shows the outline of it and the rest is all white. How can I have it actually display the image?
Thanks!
I have an image that I want to display on a UIBarButtonItem, but for some reason it only shows the outline of it and the rest is all white. How can I have it actually display the image?
Thanks!
There's other iOS7+ solution:
Extract from UIImage.h:
In Swift 3:
There is another way that does not involve coding at all.
First, place the images you want to put on the bar on the Assets.xcassets document.
Select the image on the assets browser.
Open the Attributes inspector for that image on the right vertical toolbar.
On "Render As" select "Original Image".
Even though on the storyboard the buttons will continue to be painted with the tint color, when running on the simulator the original image will be shown.
The default rendering mode for an image varies from one UI control to the other. If you set this parameter on the attributes inspector, though, you can force that an image will be always represented with a specific rendering mode.
If you need the same image to be represented with different rendering modes on different controllers, then the response from MANIAK_dobrii is more appropriate.
Nope. As you can read in the Human Interface Guidelines
UPDATE: See MANIAK_dobrii's answer for an easier solution, available in iOS 7+.
Here is how I use an image for a UIBarButtonItem: