15

I'm back again.

I'm writing an app in Swift using Xcode 7. I've added a navigation controller and on top of that a navigation item, and then a bar button. I'm trying to change the image of the bar button to a png that I've imported into Xcode. However, it just shows this in the design and also when I run the app. It just shows a blue smudge in the navigation area.

bar button image not appearing!

I've tried importing the image into the project and also into images.xcassets with the same results.

Anyone know what may be wrong here?

Here's the image I've been trying to add and the settings I currently have.

image I'm trying to add

Settings:

settings of image

1
  • I guess: The bar button's tintcolor is default? And the bar button is set as "System"? Try changing it to "Custom" perhaps? Commented Sep 28, 2015 at 16:35

2 Answers 2

39

The way to resolve navigation button images appearing as blue is to select the image set in Assets.

And then choose Original Image from the Render As select options.

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

Solves the problem for me. It should be the accepted answer.
5

You should have a image with alpha.(The sample image you posted has white background). Also you should set the image with template mode. I dont know how to do that in Interface builder. This is a sample code to convert the image to template.

var image = UIImage(named: "").imageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate)

3 Comments

Okay thanks! When you say an image with alpha, should this still be in a PNG format or should it be another format, such as JPG or something?
yes it should be png. jpg doesnt have alpha channel.
Had a look into this, and this isn't the issue. It does have a transparent background in the image. Thanks for the recommendation anyway.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.