How Is It I Can Animate the Change in Bar Tint Color of a Uinavigationbar But Not a Uitabbar

UITabBar tintColor is not changed storyboard

Use this code in didFinishLaunchingWithOptions: method of your appDelegate

[[UITabBar appearance] setSelectedImageTintColor: [UIColor redColor]];

Replace red color with color you want.

UINavigationBar & UITabbar tintColor not working in iPhone6Plus

Goto Settings > General > Accessibilty > Increase Contrast and turn off Darken Colors.

Check this answer.

UINavigationBar.appearance().tintColor does not work in Swift

The issue was due to the navigationBar not being initialized at ViewWillAppear time possibly for a IOS 9 bug. I solved the issue by optionally accessing it as in:

self.navigationController?.navigationBar.barTintColor = barColor;

This code is fine from iOS7+ and so no condition is needed.

UINavigationBar appearance refresh?

The appearance proxy only affects the look of newly initialized views. Setting colors on the appearance proxy will have no effect on navigation bars that are already visible.

You'll need to manually update your current view; for example:

self.navigationController.navigationBar.barTintColor = [UINavigationBar appearance].barTintColor;

How to customize tintColor and resize UITabBarItem

EDIT:
You are missing breaks in your switch statement:

switch item.tag{

Also, you are doing a switch on the tag and I don't see anywhere you have tagged them accordingly in your code. You should get the index of the item instead.

I am not a Swift coder, this is how you do it in Objective-C to give you a hint:

NSInteger indexOfTab = [[self.tabBar items] indexOfObject:item];

Then you do your switch statement of indexOfTab.

Here is the Swift version.:

override func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {
print("the selected index is : \(tabBar.items.index(of: item))")
}

If you want to individually change the "tintColor" , you should set a custom selectedImage instead.

Beware:

By default, unselected and selected images are automatically created
from the alpha values in the source images. To prevent system
coloring, provide images with alwaysOriginal.

As far as the documentation goes, there are no "tintColor" property for a UITabBarItem.

However, the UITabBar itself has a tintColor property. But this is not setting anything individually.

Tint Color

You can specify a custom tint color for the bar background using the
Tint (barTintColor) field. The default background tint color is white.

Use the Image Tint (selectedImageTintColor) field to specify the bar
item’s tint color when that tab is selected. By default, that color is
blue.

Regarding your resize methods, you should resize your original image instead, or check this question if it does fit your needs. However, the UITabBar and UITabBarItem customizations are limited to what you can read in the documentations.

If you want to further customize things individually, I suggest you search for or create a custom solution instead.

How to change the background color of tab bar programatically?

You should use self.tabBar.barTintColor or have a look at UIBarStyle and self.tabBar.barStyle and see if that works.



Related Topics



Leave a reply



Submit