Reputation: 541
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
Reputation: 91
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
Reputation: 11
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
Reputation: 482
Just choose an image in the Bar item section. About the selectedImage, check this selectedImage Apple developer documentation
Upvotes: 0
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.
Upvotes: 2
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
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
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