Blur UINavigationBar like the photo app - ios

How can I achieve a blur on a UINavigationBar similar to the one found in the Apple photos app?
When I use this code I cannot even see my bar:
[self.navigationController.navigationBar setBackgroundImage:[UIImage new]
forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.shadowImage = [UIImage new];
self.navigationController.navigationBar.translucent = YES;
self.navigationController.view.backgroundColor = [UIColor whiteColor];
And in AppDelegate.m
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];

The behaviour you are looking for is called translucency, and is the default behaviour of aUINavigationBar. Is this behaviour not occuring by default in your application? What have you tried so far? Some more information could help.
Here's a link to the documentation for this property specifically.
EDIT: I've found a similar question on SO with an answer that may help you if you're using a custom background image for the bar. Find it here.

The easiest way to make a translucent navigation bar is to do nothing, since that is the default.
You are basically preventing that from happening. Let's look at your code:
A bar's tint color is not its color. It is the color of its buttons and images. If you make the tint color white and background color white, you are creating white buttons on a white background. That is going to be hard to see!
The color of the bar, on the other hand, is the barTintColor. Set that, and set the translucent to YES. Experiment with various barTintColor values and see what happens.
Do not set the background color, as this complicates things.
And above all do NOT set the background image, especially not to an empty image, since this overrides everything else and punches a hole in the navigation bar, making it completely transparent.

Related

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];

UIActivityViewController compose window navigation bar color

When choosing a sharing option from the activity view such as message or email composing, the navigation bar (or is it a toolbar) and title colours look terrible. The title and status bar items are almost unreadable.
I have tried to change navigation bar and toolbar tint, barTint, background and title colours with no luck. Also tried to toggle between default and light styles.
Changing navigation bar tint colours on the main view itself also renders no difference.
Any idea on how to solve this?
Are you using a custom background image for the navigationbar? If so, you need to set the background image to nil before presenting the compose sheet. Something like:
[[UINavigationBar appearance] setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
Otherwise,
[[UINavigationBar appearance] setBarTintColor:[UIColor WhiteColor]];
should work.

How can the appearance of Button Shapes enabled through the Accessibility settings be influenced in iOS 7.1?

The release of iOS 7.1 brings the availability of Button Shapes under the Accessibility settings. I've noticed that their appearance can be inconsistent within my app. Mostly, I'm getting a black background after having implemented a UIBarButtonItem using Interface Builder. Touching the button but not fully tapping it results in the image turning gray. How can the appearance of the button shapes be influenced so that they will not look so out of place as having a solid black background and more like the gray background as shown in the attached image? In this case I do not want to use a custom control.
This feature seems to be a little buggy in iOS 7.1. The setting that seems to influence the appearance the most is actually the barTintColor on your UINavigationBar.
Some examples:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[UINavigationBar appearance] setBarTintColor:[UIColor lightGrayColor]];
return YES;
}
When I first launch, the back button looks fine:
Then when I go to landscape, it looks way too dark:
And it then stays too dark when I go back to portrait:
The same thing happens when I use [UIColor orangeColor] as the barTintColor.
First it`s fine:
In landscape it gets messed up:
And it then stays that way:
So it clearly looks like a bug in iOS 7.1. One thing that can be done is to set a background image for the back button. This background will then display whether "Button Shapes" is activated or not. Example:
UIImage *backButtonImage = [[UIImage imageNamed:#"back_button.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0.0f, 17.0f, 0.0f, 1.0f) resizingMode:UIImageResizingModeStretch];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButtonImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButtonImage forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButtonImage forState:UIControlStateNormal barMetrics:UIBarMetricsLandscapePhone];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButtonImage forState:UIControlStateHighlighted barMetrics:UIBarMetricsLandscapePhone];
So the big question is: Can we set the button background image when "Button Shapes" is turned on in a way that is independent of the barTintColor?
-[UINavigationBar setTranslucent:NO] seems to correct this. I don't know why, but it does.
Alas, we couldn't set -[UINavigationBar setTranslucent:] using UIAppearance so had to sprinkle it around the app.
I just ran into an issue similar to one described in the comments of one of the answers here while using a barTint color fairly close to black. My button shape backgrounds were nearly the same color as the barTint on a few of my UINavigationBar instances, rendering them almost impossible to see (especially when the buttons were not enabled). I tracked down the difference in these instances to be the value of the UINavigationBar instances barStyle property.
With barStyle set to UIBarStyleDefault, the button shapes would show up with a background color. With barStyle set to UIBarStyleBlack, the buttons shapes would show up with a light color. You can also notice this in the storyboard, as the title shown in the navigation bar will be black with the default style and white with the black style.
You can change each navigation bar's style in your storyboard/NIB, or alternatively you can add the following line of code where you setup your appearance proxies (typically in application:didFinishLaunchingWithOptions:):
[[UINavigationBar appearance] setBarStyle:UIBarStyleBlack];

In iOS 7, how do I have a nav bar with a dark background color, but have it transparent and blurred?

With my app and iOS 7, I want to have a green background for the navigation bar.
From what I see, I have two options: set the background color directly with a UIColor corresponding to green. This causes the green to be very washed out, but it does cause it to be transparent and blurred.
The other option I figured is to create a green background image that you manually set transparent yourself, then set this image as the nav's background image. This works 95%, but the background is not blurred. It does keep the right color and make it transparent however.
What is the correct way to do this? For instance, the new Facebook app for iOS 7 accomplishes this beautifully with their blue.
Is this the effect you're looking for?
I did this using the bar's tint color:
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:0.0f green:0.4f blue:0.0f alpha:1.0f]];
Of course, you could also use a navigation bar instance directly instead of using the appearance proxy.

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