Black line header ios 7 - ios

I'm trying to adapt my iOS 6 app to the new iOS 7 and I have found a problem that I can't fix.
As you can see in the images, it appears a black line in the header image. I think that this black line is because the background image is duplicated and the black line is just the end of the image and where starts the other.
pic 1 http://d3j5vwomefv46c.cloudfront.net/photos/large/810043729.png?1379670640
pic 2 http://d3j5vwomefv46c.cloudfront.net/photos/large/810043923.png?1379670706
The white one is a white image background
What I have done right now is to put the edges to none:
if ([self respondsToSelector:#selector(edgesForExtendedLayout)]) {
self.edgesForExtendedLayout = UIRectEdgeNone;
}
EDIT:
If I comment the line where I assign the image to the background, I can't se the black line! There all white, obviously without the image "forex crunch". So now, the question is, how can I put a background image in the navigation bar in iOS7?

What I have read in the Apple developers forum is to create an image with 64px instead of 44px. That's the solution for this problem

Only thing to do is set ShadowImage with this code and black line is off.
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed: #"navBarBack"]
forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setShadowImage:[[UIImage alloc] init]];
In this case I put navBarBack.png as navigationBar background. This image has 640pxx96px.

Related

How to set a UINavigation size to fit the background image size?

I've set my UINavigationBar background image to some image, like this:
UINavigationBar *navBar = self.navigationController.navigationBar;
UIImage *image = [UIImage imageNamed:#"Menubar.png"];
[navBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
but I cant really see the whole image since its bigger than the default size on a UINavigationBar.
So two things please:
How to set a UINavigation size to fit the background image size?
I dont want to see the battery and time bar in the background, so my image will cover it.
It's not possible to set UINavigation size (take a look at this question), you have to fit the background image instead
It's impossible to cover the status bar, but you can easily hide it. See the example here
you can easily remove status bar using info.plist file
just addRow and write "Status bar is initially hidden" and set value "YES"
end check to navigationBar
iOS. How to change UINavigationBar height and change frames of the others subviews at once?

Blur UINavigationBar like the photo app

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.

Strange appearance of NavBar background image on iOS7

The following code for setting bkg image of Navigation bar works well on iOS6, but gives strange result on iOS7.
UIImage *navBackgroundImage = [UIImage imageNamed:#"nav-bkg.png"];
[[UINavigationBar appearance] setBackgroundImage:navBackgroundImage forBarMetrics:UIBarMetricsDefault];
This is result on iOS 6.
As you can see something is wrong for iOS 7.
UPDATE
resized to 64x64px
Guessing because the nav bar is larger on the Y-axis on iOS7 (since it includes the status bar) and your image is just sized for the iOS 6 nav bar. Create an image that is large enough for both versions.
You can see that on ios7, the images is also behind the status bar, and the scrambled part of the image bottom is exactly the height of the status bar.

iOS 7 Navigation Bar

Trying to use a background image that is bigger that than the regular size with some details that hang off the bottom.
So I'm doing this to set the image:
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:#"nav_bar_home.png"] forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setClipsToBounds:NO];
[self.navigationController.navigationBar setTranslucent:NO];
And It's still getting clipped.
Some other things I've tried:
Splitting the image up in Photoshop and setting the top 44points (the size that logs out when I log out the navigationBar's frame) to the backgroundImage and the rest to the shadowImage.
From memory this worked fine in iOS 5, 6.
Is there a nice way to do this now? Thanks :)
I'm pretty sure that I remember from one of the WWDC 2013 videos that what you were doing in iOS 5 and 6 (nav bar background view larger than the nav bar "with some details hanging off it") was considered wrong and they are no longer allowing it.
However, if you are supplying your own background image you can add a custom shadow image.

White pixels around custom navigation bar image

In my iOS 5+ app, I use a custom navigation bar image, with custom navbar buttons.
First of all, here is how I tell my app to use the images :
In AppDelegate.m :
UIImage *navBarImage = [UIImage imageNamed:#"Navbar"];
[[UINavigationBar appearance] setBackgroundImage:navBarImage forBarMetrics:UIBarMetricsDefault];
UIImage *barButton = [[UIImage imageNamed:#"Nav-button"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 6, 0, 6)];
[[UIBarButtonItem appearance] setBackgroundImage:barButton forState:UIControlStateNormal
barMetrics:UIBarMetricsDefault];
So, the images are used. Great. But, there are a couple of things happening :
• First, on my button, under the bottom corners, au few white pixels appear (they're not on the original image, that's for sure). I also use a custom back button, and same thing happens. This seems to be more visible under iOS 6 than iOS 5.
• When I open a modal VC, the navigation bar is "filled up to the status bar" with white pixels. Only for a modal VC.
Here are screenshots of the situation.
iOS 5 , main VC.
iOS 5, modal VC.
iOS 6, main VC.
iOS 6, modal VC.
So, what can I do ? The white pixels under the buttons are not highly visible (a bit more for the back button), but I really want a nice design for the app, and this doesn't contribute at all..
Concerning the modal VC, I can use a "rectangle" image, which could cover the white pixels, but again, regarding design consistency, I'd prefer to use only one navigation bar..
As always, any explanation / solution / hint is greatly appreciated ! ;)
Thanks.
EDIT :
I just noticed that under iOS 6, the white pixels on top of the navigation bar are rounded, as the navigation bars in iOS 6.. Strange.. :)
Hm! just for testing purpose, can you download the following sample image for a navigation bar background and try this image instead? Just let us now how it looks with this image.
I'm just guessing, but i suppose your image is not pixel perfect for the navigation bar dimensions! Probably a few pixels below the optimum height for the navigation bar.

Resources