Reputation: 2596
I have set background image to UINavigationController
.
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"NavigationBar.png"] forBarMetrics:UIBarMetricsDefault];
And it appears like this. Why image is divided ? One can see the dark line. What was that ?
Upvotes: 0
Views: 559
Reputation: 178
I think your approach to add the custom navigation bar with image is as follows:
Apply the following setting for respected view control: 1.Select the View controller first in storyboard. 2. Go to Editor-> Embed in-> Navigation controller like as follow
3.Also do the following setting for respected view controller .
4. write the following code inside -(void) viewWillAppear:(BOOL)animated
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"sample.png"] forBarMetrics:UIBarMetricsDefault];
Image size should be proper without pixelated as per apple standards. i.e 1) 320 X 44 For regular image 2) 640 X 88 for Retina image
Hope this steps will work for you. Thanks.
Upvotes: 0
Reputation: 548
Maybe you need to clean the project files (Shift+Command+K) and (Shift+Alt+Command+K). You may also want to try deleting the derived data under Window > Organizer > [Project Name] as well as deleting the app off the iOS device (stop project after build in xCode, then delete the app just like on iDevices). If that doesn't work, try changing the image size, or there may be something wrong with your image file.
Upvotes: 0
Reputation: 14419
The line you see is the bottom of your image.
With iOS7, Navbar includes the status bar.
So one simple solution could be to just add 20px to the top of your background image.
Upvotes: 2
Reputation: 3207
I tried your way with a image and I didn't faced your issue with image for navigation bar. As shown below:-
Upvotes: 0