Change UITabBar tint colors in the More menu
To do what you need, you should use images by creating UITabBarItem for each controller and add an image and a selected image.
See Apple Documentation about UITabBarItem
Otherwise looks here, from @Aaron Brager :
- How to set UITabBarItem's unselected tint, ***including system items*** (iOS7)
- UITabBarController unselected icon image tint
Edit after seing the full code
First there is many mistakes in your project, assets should be in xcassets folder, in view didload write your code after the 'super viewDidLoad]', etc.
About your problem, in your viewDidLoad method in the FirstViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
// Your code start here, not before the super
[[UITabBar appearance] setTintColor:[UIColor redColor]];
// Get table view of more new viewController
UITableView *view =(UITableView*)self.tabBarController.moreNavigationController.topViewController.view;
view.tintColor = [UIColor redColor]; // Change the image color
if ([[view subviews] count]) {
for (UITableViewCell *cell in [view visibleCells]) {
cell.textLabel.textColor = [UIColor redColor]; // Change the text color
}
}
}
How to change 'More' view controller tintColor of UITabBarController?
You can access that view controller using the moreNavigationController
property of UITabBarController
.
As you can read in the documentation:
This property always contains a valid More navigation controller, even if a More button is not displayed on the screen. You can use the value of this property to select the More navigation controller in the tab bar interface or to compare it against the currently selected view controller.
Therefore you can do something like
self.tabBarController.moreNavigationController.navigationBar.tintColor = [UIColor orangeColor];
Change the color of items in the more tab
As far as I know you can do it only programmatically in UITabBarController
.
This code should do the job
moreNavigationController.view.tintColor = .blue
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.
Change tab bar tint color on iOS 7 and later
Try the below:
[[UITabBar appearance] setTintColor:[UIColor redColor]];
[[UITabBar appearance] setBarTintColor:[UIColor yellowColor]];
To tint the non active buttons, put the below code in your VC's viewDidLoad
:
UITabBarItem *tabBarItem = [yourTabBarController.tabBar.items objectAtIndex:0];
UIImage *unselectedImage = [UIImage imageNamed:@"icon-unselected"];
UIImage *selectedImage = [UIImage imageNamed:@"icon-selected"];
[tabBarItem setImage: [unselectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[tabBarItem setSelectedImage: selectedImage];
You need to do this for all the tabBarItems, and yes I know it is ugly and hope there will be cleaner way to do this.
Swift:
UITabBar.appearance().tintColor = UIColor.red
tabBarItem.image = UIImage(named: "unselected")?.withRenderingMode(.alwaysOriginal)
tabBarItem.selectedImage = UIImage(named: "selected")?.withRenderingMode(.alwaysOriginal)
Changing tab bar item image and text color iOS
From UITabBarItem class docs:
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
UIImageRenderingModeAlwaysOriginal.
The clue is not whether you use UIImageRenderingModeAlwaysOriginal, the important thing is when to use it.
To prevent the grey color for unselected items, you will just need to prevent the system colouring for the unselected image. Here is how to do this:
var firstViewController:UIViewController = UIViewController()
// The following statement is what you need
var customTabBarItem:UITabBarItem = UITabBarItem(title: nil, image: UIImage(named: "YOUR_IMAGE_NAME")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal), selectedImage: UIImage(named: "YOUR_IMAGE_NAME"))
firstViewController.tabBarItem = customTabBarItem
As you can see, I asked iOS to apply the original color (white, yellow, red, whatever) of the image ONLY for the UNSELECTED state, and leave the image as it is for the SELECTED state.
Also, you may need to add a tint color for the tab bar in order to apply a different color for the SELECTED state (instead of the default iOS blue color). As per your screenshot above, you are applying white color for the selected state:
self.tabBar.tintColor = UIColor.whiteColor()
EDIT:
How to set the Navigation Bar Color of the Tab Bar Configure Menu
Use int AppDelegate
tabBarController.moreNavigationController.navigationBar.tintColor = [UIColor blackColor];
iOS - How to change color of icons in tab bar moreViewController
Ok, from long research on the web and answers in this thread, it seems that it is not possible on iOS7 to change color of the icons (gray color) displayed in moreViewController
of UITabBarController
. The best solution for customizable tab bar is to implement it (or use some library).
Thanks!
Related Topics
How to Update Particular Value of Child in Firebase Db
Fbsdk (New Facebook Sdk 4.0) Implementation Is Not Working for Login with Facebook
How to Use Urlsession with Proxy in Swift 3
Swift How to Add Background Color Just Around Text in a Label
Outline Uilabel Text in Uilabel Subclass
No Such Module "Sinch" Xcode 9.1 Swift 4
Swift: Sort Array by Sort Descriptors
Swift/How to Call Delegate with Popviewcontroller
How to Access Property or Method from a Variable
Format Currency in Textfield in Swift on Input
Extract 4 Bits of Bluetooth Hex Data
Uitextview - Adjust Size Based on the Content in Swiftui
Multiple Image Pickers in One Controller
How to Make Uiscrollview Zoom in Only One Direction When Using Auto Layout
Using Huffman Coding to Compress Images Taken by the iPhone Camera