Adding translucent toolbar to navbar causes rendering issue in iOS 7 - ios

I have an iOS app that I want to to add more than just 2 items to my navigation bar. One way I have read to do this is to add a toolbar one of your bar button items and then add however many items you want to the toolbar. This seems to work well, except my navbar is translucent (iOS 7 default). This causes the toolbars opacity to overlap with the navbar, causing a noticeable white square if the user scrolls dark content underneath the navbar.
If I could get the toolbar background to be clear, then this would resolve my problem. Does anyone know how to do this, or another way around this issue? Just setting the background of the toolbar to clear does not seem to work.

How about
toolbar.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.1];

Related

UIBarButtons styled with System Items, disappear after rotation

In our app the initial ViewController is embedded in a regular Navigation Controller. We have two UIBarButtons, located in the upper right of the navigationbar. One of the buttons is styled with a custom image and the other one with the camera icon from the provided System Items.
Here is the problem:
When the app starts in portrait, both bar buttons are visible. After rotating the device to landscape, the UIBarButton with the camera symbol disappears and no longer shows up when rotating back to portrait again.
I have no outlets to neither the navigationbar nor the UIBarButtons, no adjustments in code are made whatsoever.
The button that disappears after rotation still exists in the navigationbar, if you tap where it is supposed to be shown, the action is triggered. It seems to only be the image that is removed for some reason. And only if the button is styled with any of the System Items.
Can anyone think of a reason why this problem occurs?
Ok, this problem was related to appearance proxy code that I had in my appDelegate:
[[UITextField appearance] setTintColor:[UIColor darkGrayColor]];
[[UITextView appearance] setTintColor:[UIColor darkGrayColor]];
Apparently these two statements affect the behaviour of the barbutton appearance. I cannot see why, but I am sure that there is a good reason.
Getting rid of these two statements in the appDelegate solved the problem.

Change UIWebView Done button color

I am using a UIWebView to display content in an app and would like to change the color of the Done button that is displayed whenever a select control is used.
It is currently displaying as white on gray which is hard to see.
The "Done" button is white because you are probably setting the tintColor to white for all UIBarButtonItems using UIAppearance. That affects the "Done" Button in the picker view which also happens to be a UIBarButtonItem.
So you have to exclude the "Done" button in the picker view from the global white tintColor. I don't know if you only need the white UIBarButtonItems in your navigation bar, but if you do you could do this to only set the tintColor for the bar button items in your navigation bar and leave all other UIBarButtonItems untouched:
UIBarButtonItem.appearanceWhenContainedInInstancesOfClasses([UINavigationBar.self]).tintColor = UIColor.whiteColor()
However this is only available in iOS9 and the old appearanceWhenContainedIn method that works for older iOS versions is not available in Swift.
So, if you are working with Swift and you have to target earlier iOS versions than iOS9 this is probably not working for you. In that case you have to remove the UIAppearance setting for the white tintColor and set the tintColor for the UIBarButtonItems in your navigation bar "manually" without using UIAppearance.
Another possible solution is to just do
UIPickerView.appearance().tintColor = UIColor.blueColor()
put this in your AppDelegate and you are ready to go!

Set navigation bottom bar color programatically

Is there away i can set the colour of may navigationController bottom bar colour. Similar to setting top bar in the app delegate with
[[UINavigationBar appearance]setBackgroundColor:color];
can bottomBarColor or something be used?
thanks
The problem is you mistakenly believe that the bar you see at the bottom is a real bar instance/object.
It is not, it is just a simulation of a future situation.
With bar metrics feature in Interface Builder, you can simulate a situation when you view controller will be a part of larger view hierarchy which will contain a bar at a bottom. You can simulate this in design time, and this way you can adjust your AutoLayout constraints, or frames, as if the bar was there so this way the constraints/ frames will behave correctly when it really happens.
If you want a bar with orange colour, you need to have a real bar instance added to some view controller, and change its appearance. But I repeat, it needs to be a real bar instance, not a bar metrics simulation.
Btw, it is AFAIK not possible to put a navigation bar to the bottom, for that you need to use UIToolbar class.
If you want to set the toolbar color globally do this in your AppDelegates didFinishLanchingWithOptions method:
[[UIToolbar appearance] setBarTintColor:[UIColor blackColor]];
Of course your selected color doesn't have to be black.

iOS 7: UINavigationBar not in UINavigationController does not draw translucency correctly

I have a UINavigationBar (not in a UINavigationController) in my view hierarchy, but it sometimes does not draw its translucent background correctly. In the image below, I have a navigation bar with barTintColor = [UIColor redColor] and content underneath it. For some reason, the left and right sides are transparent. Why is this the case, and how can I fix this? (I also think I'm having more of this after switching to iOS 7.1.)

UIToolbar incorrect colour in iOS7

When I set the bottom UIToolbar to black on the view controller, it appears as a more greyish colour (the same thing happens with other colours--it sort of fades them out). What I assume is happening is that in iOS7 the toolbar seems to adapt the colour of what is beneath it (currently white) which makes for the duller colour.
I've updated the view controller so that the "extended edges" options are turned off but still get this effect. Has anyone else had this issue yet?
UPDATE:
I resolved the issue by setting the background colour of the UIToolbar to black (something I haven't had to do in previous versions of iOS). If anyone can think of a better solution, let me know.
All tool- and navigation bars in iOS 7 have a translucent property.
This causes the effect, where the background shines through in blurred form (just like the control center).
Just set YourToolbar.translucent = NO;.
SET the t*ranslucent property to NO*:-
IN iOS 7 you need to set the barTintColor Property-
UIToolbar *doneToolbar=[[UIToolbar alloc]initWithFrame:CGRectMake(0, 584, 320, 44)];
doneToolbar.translucent=NO;
doneToolbar.barTintColor=[UIColor blackColor];
[self.view addSubview:doneToolbar];
I have used it its working fine...
setting the background color instead of the bar tint worked for me
I set the bar tint to default, the translucent property to NO and the background to the color i wanted and it worked for me.

Resources