TeKnofUNk
TeKnofUNk

Reputation: 541

Image is not showing up for tab bar item

I uploaded an image to assets folder and assigned the image to 1x, 2x and 3x. selected the table view controller of the respective tab bar item -> selected the Attributes -> assigned the image to the image field in the Bar Items section.

After running the application a Blue Square box is showing up on selection and Grayed out square box is showing up on selection of a different bar item.

Where am I going wrong?

Upvotes: 34

Views: 30159

Answers (7)

Er. Amreesh Arya
Er. Amreesh Arya

Reputation: 91

Screen Shot for Convert Image Render

First drop your image in the Assets or Images section then click on the image and show to option for Render As in the right side menu. So change the option from default to Original Image same as shown in above screenshot.

Upvotes: 2

I had this problem due to the tint color on my UIBarButtonItem this did the trick!

BarButtonItem.image = UIImage(named: "yourImage")?.withRenderingMode(.alwaysOriginal)

Upvotes: 1

Farrukh Makhmudov
Farrukh Makhmudov

Reputation: 482

Just choose an image in the Bar item section. About the selectedImage, check this selectedImage Apple developer documentation

Upvotes: 0

Rakesh Lohan
Rakesh Lohan

Reputation: 21

add tab bar item under view controller, if you embed in view controller in navigation controller tab bar item must be come under Navigation controller.

  • View controller when icon not shown

view controller when icon not shown

Upvotes: 2

kiko carisse
kiko carisse

Reputation: 1784

When you click on a tab bar icon in one of your view controllers, on the right hand side is where you set the image. What's misleading is that there are two places to set the image in the right sidebar. Under Tab Bar Item > System Item (custom) below that selecting the custom image. Then right below that whole first set there is Bar Item > Image. Mine wouldn't show up until I set the Bar Item > Image as well.

Upvotes: 24

Cerlin
Cerlin

Reputation: 6722

If you follow B B's answer, the image will always render in original form in all the places.

for my tabbar implementation i had to do the following

tabBarItem.selectedImage = UIImage(named: "home").withRenderingMode(.alwaysOriginal);
tabBarItem.image =  = UIImage(named: "home");

So here the image will be rendering as original when the tab is SELECTED (ie, tint will not be applied) and tint will be applied to the tab bar item image when that tab is not selected

@kishor0011: This should fix your problem.

Upvotes: 3

B B
B B

Reputation: 1950

Go to Assets folder. Select your tab image. On the right side under Attributes you will find "Render As". Select "Original Image".

Upvotes: 122

Related Questions