I need to customise the UITabBar as shown in this image, for my project. Is it possible to do so? And if so, how can it be done? the selection field should have this "orange" shade
You can achieve this by doing :
yourTabBar.selectionIndicatorImage = [UIImage imageNamed:#"yourImage.png"];
Create the orange gradient as an image and use it in the code above.
Hope this helps.
Related
I'm using tabbar with four tabs with title. I'm setting different color for selected and unselected tabs. But only for the first tab, the selected and unselected colors & title are getting overlapped. Whenever I'm selecting first tab, title is getting added again and again. I have attached screenshot as well.
In storyboard
Anyhelp could be appreciated. Thanks in advance.
You problem is most likely from the color you use for unselectedItemTintColor, which you have set to have transparency. This color should probably be solid. Try changing it to a solid version of what you want to see, like #EB989E.
Also be aware that you are setting an internal property, and as such it may change or disappear in a future release of iOS.
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)
One of my apps has three UIButtons on it, and they use images that I got from icons8. In the code, I change the tint color and it works fine. Whatever I set the tint color to is what color the button image becomes that color.
Today I wanted to add a fourth button to mute sound. I downloaded the images that I wanted from icons8, added the button and set it up like I have the rest of the buttons set up. The new button is not changing colors like the rest of them. I'm certain that it has to do with the image, because if I select a different image, it changes color. I also tried using the new image on one of the older buttons and it would not change color.
My question - is there anything special that needs to be done to an image to make it work with tint color?
Try setting the image to render as a template image. You can do this in your .xcasset folder selecting the image set, opening the attributes inspector and setting render as to "template image."
What I did was follow the #beyowulf instructions and on the code I just did this
yourBtn.tintColor = .white (or other color)
this worked for me
I have an UITabBar and set 2 images for a tab(active item, deactive item). On deactive item tab icon shown properly as:
Image here
but when those item is active, icon not shown properly:
Image here
Can anyone help me to fix it? I was that it will colour just borders of the icon, not entirely
Check this screenshot: At right side of the screen see 'Rendered as' text and select drop down and use Original image. Your problem would be solved. Hope this helps..
You need to use UIImageRenderingMode for that.
UIImage *imgNormal=[UIImage imageNamed:#"normal.png"];
imgNormal=[imgNormal imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
UIImage *imgSelected=[UIImage imageNamed:#"active.png"];
imgSelected=[imgSelected imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
tabBarItem.image = imgNormal;
tabBarItem.selectedImage = imgSelected;
Hope it helps :).
How do you display a background color for the selected tab view? I know that you can tint it when it's selected, however, I don't think this is of much use if you can not change the background color.
Also, how do you add a divider for each tab?
Thanks in advance
Set an image as the background for the selection:
tabBarController.tabBar.selectionIndicatorImage = [UIImage imageNamed:#"image.png"];
As for the dividers, prior to iOS 7 you could simulate them by adding an image for the selected state and another for the unselected state for each tab. See more here. Those methods were deprecated in iOS 7, though.