Custom UITabBar unselected item's color
you can use .AlwaysOriginal
tabBarItem.selectedImage = UIImage(named: "first-selected")!.imageWithRenderingMode(.AlwaysOriginal)
How do you change the color of unselected items in a Tab Bar?
Make the icon images Black, if they are white Im not sure it will work. As in the actual image themselves should be black in the assets folder not white.
If you add a tabbar from the story board you can put these line of code in that method in the appDelegate method shown in your post
UITabBar.appearance().barTintColor = UIColor.black
UITabBar.appearance().tintColor = UIColor.red
UITabBar.appearance().unselectedItemTintColor = .white
Unselected UITabBar color?
SO says i cannot delete the accepted answer (i tried), but obviously, there are a lot of upvotes for comments that this doesn't work for iOS 7.
See the other answer below with many more upvotes, or the link in @Liam's comment to this answer.
for iOS 6 only
It should be as simple as this:
[[UITabBar appearance] setTintColor:[UIColor grayColor]]; // for unselected items that are gray
[[UITabBar appearance] setSelectedImageTintColor:[UIColor greenColor]]; // for selected items that are green
Change tintColor of unselected UITabBarController item title and background image
Figured it out!
Use this to change the color of the text:
[[UITabBarItem appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName : [UIColor greenColor] }
forState:UIControlStateNormal];
[[UITabBarItem appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName : [UIColor blackColor] }
forState:UIControlStateSelected];
And make sure that image rendering mode is set to ORIGINAL for the images
UIImage *deselectedImage = [[UIImage imageNamed:@"deselectedImage"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
UIImage *selectedImage = [[UIImage imageNamed:@"selectedImage"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
how can I set the tintColor for the tabBar item for the unselected state
You can set the tint color for selected and unselected tab bar buttons like this:
[[UIView appearanceWhenContainedIn:[UITabBar class], nil] setTintColor:[UIColor redColor]];
[[UITabBar appearance] setSelectedImageTintColor:[UIColor greenColor]];
[self calculateFolderSize];
The first line sets the unselected
color - red in this example - by setting the UIView's tintColor
when it's contained in a tab bar. Note that this only sets the unselected
image's tint color - it doesn't change the color of the text below it.
The second line sets the tab bar's selected image
tint color
to green.
May be it will help you.
Related Topics
Hmac Sha512 Using Commoncrypto in Swift 3.1
Play Mp4 Using Mpmovieplayercontroller() in Swift
Is There an Kotlin Equivalent 'With' Function in Swift
Why Can't I Use .Reduce() in a One-Liner Swift Closure with a Variadic, Anonymous Argument
How to Capture Multiple Arguments Weakly in a Swift Closure
Using Uilexicon to Implement Autocorrect in iOS 8 Keyboard Extension
How to Trigger Xcode's 'Update to Latest Package Versions' from Command Line
Integer Literal Overflows When Stored into 'Int'
Swift Unit Testing with Xctassertthrows Analogue
Nssortdescriptor Sorting Using Nsdate in Swift
Swift 3: Converting Data to String Returns a Nil Value
Ambiguous Use of Operator '-' in Swift with 'Abs()'
Swift-Setting a Physics Body Velocity by Angle
JSONserialization.JSONobject Performance in Swift
Property with '= {Return}()' or '{Return}'
Can't Create Default Closure Parameter in Array Extension Method in Swift