UITabBar not updating appearance after Load - ios

I am having a problem with UITabBar, seems like the call to
[[UITabBar appearance] setSelectedImageTintColor:barColor];
does nothing once the tabbar is showing, if i put the line in the ViewDidLoad (ViewWillAppear) it does work.
Any hint?

in the Apple docs for UITabBar it says
"The tint color to apply to the gradient image used when creating the selected image."
Note the creating, meaning that it reads this property when initalising/creating the tab bar, but it can't be set after. If you wanted to dynamically you'd have to get a little bit fiddly and overlay a semi transparent UIView over the selected image to change the colour, but it's not really ideal... There is some examples of that type of thing here
Changing Tint / Background color of UITabBar

Related

How can I set the color of a custom back arrow image with UINavigationBarAppearance?

I have an iOS app that uses a custom back chevron for the back button in navigation bars with custom background colors and shadows and such. I'd like to set the color of that back indicator image to something besides the default blue. How do I do that with the new UINavigationBarAppearance APIs?
I have tried:
Setting the back indicator image to a template image of my shape - this works, but doesn't affect the color.
Setting titleTextAttributes on the normal variant of the buttonAppearance, specifying NSForegroundColorAttributeName
Setting titleTextAttributes on all variants of the backButtonAppearance, specifying NSForegroundColorAttributeName and NSBackgroundColorAttributeName
Setting tintColor on the navigation bar directly - this affects the back indicator during animation of a new navigation item, but at the end of the animation it goes back to blue.
The tintColor works for me. The attached screencast shows (using slow animations) that having set the tint color to black, it stays black, both pushing and popping:

Set background color (not Text Color) of Back button in UINavigationBar IOS

Is there any way to set the background color of back button in NavigationBar like this
There are some post available on SO which shows how to set Tint color. But can anyone let me know if there is way to set Background Color like shown in image above. or i have to set in custom way?
for navigationBar you should setbackgroundImage
navigationController?.navigationBar.setBackgroundImage(UIImage(named: "your image name"),
forBarMetrics: UIBarMetrics.Default)
I tried with Tint color, but I can not make it work properly.
I do that by adding an UIView at the back of the UINavigationBar. In that case it must be properly positioned using Autolayout.
You have to realize, that is not actually back button background.
If you'll take a closer look at navigation bar, you will see back button has a limited width and height. Something like this:
So if you really need to customize your navigation bar, you have 2 variants:
1) set your navigation bar background image, with fixed or adapting back button background
2) implement custom navigation bar, ignoring system UINavigationBar
You can use custom image and set title manually
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:[UIImage imageNamed:#"customImage"]
forState:UIControlStateNormal
barMetrics:UIBarMetricsDefault];

iPhone not displaying accurate color

I'm working on a simple WebView app where I want the Statusbar to be the same color as the Taskbar from the website.
What I did was setting the background color of the View to the same color as the Taskbarby using the color picker. However when I run the app I'm getting a completely different color as you can see below:
These are the settings for the view:
The color code of the Taskbar is: #242424
However the color code the statusbar gets is: #1b1b1b even though I've selected the #242424 color via the color picker.
Why does it seem to do this?
It has to do with the translucency of the bar, as explained in these answers.
You also have to consider that the view extends under the translucent bar, and the view's background color will slightly change the appearance of any translucent bars above it, because of the visual effect used by the bar.
You may want to not set a specific color for the status bar, and let it inherit the bar's color, to give the task bar and status bar a uniform appearance.
Xcode Colour picker not pick exact same colour. Try this macro(set your colour code)
#define CODE_1_COLOR [UIColor colorWithRed:(140.0f/255.0f) green:(132.0f/255.0f) blue:(124.0f/255.0f) alpha:1.0f]
Also take care about Translucent property in case of navigation bar
[[UINavigationBar appearance] setTranslucent:NO];

UITabBar remove the black background

As the title states, I haven't been successful in removing the black background in the UITabBar.
I know it is possible to add a subview on top of it. But I want it to be transparent so if I add a transparent subview on top of it, it will just have the underlying black color.
Setting the tintColor made me able to change the color of the UITabBar, but when I change it to clearColor it will just be black again.
Anybody know how to remove the underlying image or color so it will be transparent?
When they added the tintColor property in iOS 5, they also added a number of other appearance-customization functionality to UITabBar. See, backgroundImage and selectionIndicatorImage, and the finishedSelectedImage and finishedUnselectedImage properties of UITabBarItem.

iOS - SearchDisplayController - SearchBar style

I'm working with SearchDisplayController and want to apply a style or tint to the searchBar.
But I noticed that the SearchDisplayController makes changes to the style of my searchBar.
For example if I use the "Dark Text Color" tint on my searchBar, when running the app, I'll obtain a grey style. But if I remove the searchDisplayController linked to the searchBar, the style in the app is ok.
This image shows the difference between the searchBar in the storyboard and in the app.
Note: If I use the default style, I don't have any problem.
I don't understand what changes the searchDisplayController adds to the searchBar.
Am I missing something or doing something wrong ?
No, you are not doing something wrong. While I'm not sure why it works this way, I can imagine that a somewhat lighter color is chosen in order to distinguish the cancel button (which will have your tint color).
What worked for me was to set the background color to black, no tint color (default), and use the Black Translucent style.
Also remember that when you set a tint color, the style is ignored.
I remember struggling with this for hours, just to get a black search bar.

Resources