iOS - How to remove highlighting of selected items in Tab Bar - ios

I am customizing the tab bar, and I don't my items to be highlighted with the tint color set to the tab bar item. I wan't the highlight to be just the image that I set for the selectedImage property of the tab bar item.
This is what it looks like now
I don't want my image to be highlighted with blue. I want it to be just the image that I set.
Please don't tell me about changing tint colors. I am not asking about tint colors here.

As per UITabBarItem documentation for init(title:image:selectedImage:) initializer:
By default, the actual unselected and selected images are automatically created from the alpha values in the source images. To prevent system coloring, provide images with
alwaysOriginal
So, in your case:
let yourTabBarItem = UITabBarItem(title: yourTitle, image: yourImage.withRenderingMode(.alwaysOriginal), selectedImage: yourSelectedImage.withRenderingMode(.alwaysOriginal))

Related

Bar button item image (UIImage) color changes with tint color?

I am trying to set an image for bar button item based on a condition. I need to show 2 different images. The tint color property is affecting the color of my image itself. How to change this? When i give “clear color” as tint color the image is not getting displayed at all.
Use this
Swift 2.x
var image = UIImage(named:"myImage").imageWithRenderingMode(.AlwaysOriginal)
Swift 3.x or 4
var image = UIImage(named:"myImage")?.withRenderingMode(.alwaysOriginal)
And set it to your UIBarButtonItem

How do I change the color of unselected tabs, preferably in storyboard?

Here is an answer on how to change the color of the selected tab:
Change tab bar item selected color in a storyboard
How do I change the color of the unselected tabs? Short of adding custom images for selected/unselected, which seems like too much hassle for this simple task.

Set Statusbar color to same as Nav Bar

I want the Status Bar of my app to have the exact same color as my Navigation Bar. The way I found to change the color of the Status Bar was just by creating a view in the size of the Status Bar and change the background color.
However even though I use the color picker from the Nav bar to set the color of the view I get 2 totally different colors as seen in the picture below.
I've tried mixing with the color picker, changing opacity etc, however I'm never able to hit the correct color. Any ideas on how I can get the exact same color for the status bar?
The color of the UIStatusBar is automatically set to match the color of the UINavigationBar when you set the value of self.navigationController.navigationBar.barTintColor. Is there a reason you need to set them separately?
You can do the following:
Create an UIImage containing only the color you want with a size of 64x1. You could render that image in code.
Set the image as a background image for the navigationBar. Something like:
navigationController.navigationBar.setBackgroundImage(image, for: .default)

(Swift) set inactive tab bar image's color?

I want to know how can I change the color of inactive tab bar's grey shade image. Or if someone can tell me how can I set the image of a tab bar while it's inactive?
A UITabBarItem has selectedImage and image. You can use a combination of the two to set active/inactive images.
tabBarController.tabBar.items will have all the UITabBarItems.

How to set tabbar image color ios button?

i create a 4 button like tabbar , but image show as colored ,i need show images as like tabbar image color (gray) .
Thanks
Set the icon to the tabbar like this
self.tabBarItem.image = [UIImage imageNamed:#"myImage"];
Don't use
[self.tabBarItem setFinishedSelectedImage:selectedImage withFinishedUnselectedImage:unselectedImage];
because then the image will not be automatically styled to the default tabbar style
You just need to set the image mask (gray, 1 color image with the transparency), not the complete image. According to the documentation
A custom icon that you provide for a toolbar, navigation bar, or tab
bar is also known as a template image, because iOS uses it as a mask
to create the icon you see in your app. It is not necessary to create
a full-color template image.
See for more info:
http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/MobileHIG/IconsImages/IconsImages.html%23//apple_ref/doc/uid/TP40006556-CH14-SW1

Resources