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
Alamofireimage Disk Cache Not Working
Auto Focus and Auto Exposure in Avfoundation on Custom Camera Layer
How Parsing Firebase Fdatasnapshot JSON Data in Swift
How to Unwrap the Elements of an Array in Swift? (Ie. Array<Int> as Array<Int>)
Value of Type 'Error' Has No Member 'Code'
Setting Uiimageview Image Affects Layout Constraints
Moya/Alamofire - Url Encoded Params with Same Keys
How to Refresh a Timer in a Today Widget
How to Use " Let Newswiftcolor = Uicolor(Red: 255, Green: 165, Blue: 0, Alpha: 0)
Swift:How to Convert String to String with Time Format
Get Index of Object from Array of Dictionary with Key Value
Restkit, Coredata and Swift - I Can't Seem to Fetch Results Back Out
How to Create a Rounded Rectangle Label in Xcode 7 and Swift 2
How to Calculate a Random Cgpoint Which Does Not Touch a Uiview
Using Completionselector and Completiontarget with Uiimagewritetosavedphotosalbum