Cannot set navigation bar item image in storyboard - ios

I am trying to customize a bar button item. I dragged it in the navigation bar and I can display text and predefined identifiers.
However it does not display custom images (44x44 & 22x22 px).
Any ideas what might be wrong?

I think may be you did not give the Path Extention. It will be "10-medical.png" or other path extention instead png like jpg gif etc.

Related

Adding home icon to the tab bar

I want to implement a bar at the bottom of the screen with the home button - exactly like in Instagram or Messanger apps. I was trying to use a tab bar (https://developer.apple.com/ios/human-interface-guidelines/bars/tab-bars/)
And I would like to utilize system home icon for the tab bar button/item (https://developer.apple.com/documentation/uikit/uiapplicationshortcuticontype/1623374-home)
Is there any simple and straight forward way to set this home icon for the tab bar item?
Some icons can be selected directly from the list in the button/item properties in Xcode, but this home icon is not among them.
I also saved the png from the link above, resized it to 30x30 and added as a picture for the button/item, but it's just showing a grey rectangle.
Apple may or may not provide you with some images. In general no one uses stock images but provide their own. You should do the same.
So "Adding home icon to the tab bar" is pretty much the same as for any other tab bar item. You can add your image and/or text that represents your "home" button. Some images may already be at your disposal but others must be made/bought/stolen by you.
The image you use in tab bar item is only used as a mask and not as an explicit image. What that means is that only alpha component of the image will be taken. In your case you have a black icon on white background which from alpha perspective means you have a rectangle. You will need to remove the white background and make it transparent or use another image that already has these properties.
I am not sure for tab bar but you might also try to open your assets, select your image and then in options on the right find "Render as" and set it to "Original image". Even if this will work the results will not be as you desire (at least in most cases) due to a white background on the image.
In general this option is used to set it to "template" which means whenever you use this image on your components such as UIImageView it will use it's tint color and image alpha component instead of the actual colors from the image. It is a very useful tool but again I am not sure it will work on tab bar item.
You should stop wondering if Xcode is designed to be overcomplicated. Putting aside numerous amount of bugs (and there is really a lot of them) and it being slow (it really used to be faster) it is designed very nicely. But tab bar view controller is extremely high level component. If you don't like it the way it is then simply create your own. All you need is a bottom view with your N buttons which may be shaped any way you can possibly imagine and a container view on which you set a new view controller when one of those buttons is pressed.

how to use custom icon with 2 color in tabor in swift 3?

I want to add special icon with 2 color in the tab bar but the app detect just one color I used lots of single color icons and there is no problem with them but this icon won't show as I want to be
here is the image of that Icon
the tabor background is white
try to use .jpg of the image in place of .png
If you are using image assets then change the render option as Original Image instead of Default.
Otherwise change the tint color of tabor to clear.
Try to set color you want using this code.
UITabBar.appearance().tintColor = .red
Or you can tell the system to keep the original rendering mode, so it does not use default colors. Set image like that.
... = UIImage(named:"myImage.png")?.withRenderingMode(.alwaysOriginal)

How to show text and image in bottom toolbar of a scene in xcode

I am trying to replace the bar button items in my toolbar with images. I was able to select image in the attribute inspector. But now the text is replaced with image. Is there anyway i can keep both text and image (text should be below image)
What i have is this.
Please click to see image
What i am looking for is something like this
Please click to see image
Thanks for helping.
You can place the image in the selected image attribute
And you can place the text in the bar item title attribute
Something like this
This can be done when you do to the navigation controller for that particular tab.. Like in your case navigation controller for item 1
Hope that helps

IOS Developing:Tab Bar Item's Image Display a Blue Square

The bar item images I prepared are about 35*35
and I use the Sketch to export the [1x & 2x] size images;
(I can't insert any images for instances at here because of my zero reputation//Sorry about this!)
Then it displays a blue square :<
the function and title of Item is OK
BUT just the icons are wrong
Could someone tells me how to fix it!
Appreciate!!!
I figure it out!
There is nothing wrong with your code or setting
It's about your IMAGEs
You can just look at the apps on your phone.(almost)Any tab bar item icons are in gray.
So the Icon will just display their UN Hollow parts in gray!!
[Additionally,according to official API,they wrote like this:
By default, unselected and selected images are automatically created from the alpha values in the source images. To prevent system coloring, provide images with UIImageRenderingModeAlwaysOriginal.
]
Consequently the solution is : USE Sketch to make your instance's icon heart-part to be hollow
You need to add #3x image too.

Tab Bar Item Image Does Not Show Up

I'm trying to assign a custom image to UITabBarItem in storyboard. Unfortunately, it shows me an box instead of an image.
Here's my PNG image
Storyboard:
How it appear in simulator:
As it turned out in order do display an actual image following code should be executed.
[self.activityItem setImage:[[UIImage imageNamed:#"activity.png"]
imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
Note the Rendering Mode of UIImage. You can find more about it UITabBar Reference Thanks to # Vladislav Kovalyov
Go to Assets folder. Select your tab image. On the right side under Attributes you will find "Render As". Select "Original Image".

Resources