Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove Navigationbar's bottom border iOS7

Is there a way to delete the bottom border that iOS7 automatically displays under the navigationbar?

like image 308
Gnamm Avatar asked Sep 27 '13 09:09

Gnamm


People also ask

How do I hide navigation bar on Iphone?

You can find the Website View menu in what's called the Smart Search field at the top of the Safari interface. Launch the app and navigate to a website, then tap the "aA" icon in the upper left corner of the screen. Simply select Hide Toolbar from the dropdown menu, and the toolbar will shrink to show just the URL.

How do I get rid of the transparent navigation bar?

Select the NavigationBar widget and uncheck "Translucent".

How do I use the navigation bar in Xcode?

Start with Navigation ControllerCreate a single view application in Xcode. Add two view controller into your storyboard. Create two different swift files for those view controllers and set identifiers for them. Take a button in each view controller, set constrain for them and customize as you want.


3 Answers

That does not work on iOS7 with navigation translucent or not...

A paste from Apple documentation;

Description The shadow image to be used for the navigation bar. The default value is nil, which corresponds to the default shadow image. When non-nil, this property represents a custom shadow image to show instead of the default. For a custom shadow image to be shown, a custom background image must also be set with the setBackgroundImage:forBarMetrics: method. If the default background image is used, then the default shadow image will be used regardless of the value of this property.

So basically you need to implement that setBackgroundImage. Additional note, on iOS7 you won't use appearance anymore but you'll modify the Navigation bar in the viewController context where you are now.

That is:

    [self.navigationController.navigationBar setShadowImage:[[UIImage alloc] init]];
[self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc]init] forBarMetrics:UIBarMetricsDefault];

In my case I put this in viewDidLoad (custom behavior can be added for each UIViewController in the UINavigationViewController).

like image 123
wolffan Avatar answered Oct 12 '22 09:10

wolffan


If i understand you correctly try

[[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
like image 26
muffe Avatar answered Oct 12 '22 07:10

muffe


based on muffed2k answer+ programming Thomas comment, this is what I'm using to show UINavigationBar without background image (ios5.1/6.0) and without bottom border(ios7.0) :

  if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 6)
    {
        [[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
        [[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
    }else
    {
        [[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
    }
like image 41
user1105951 Avatar answered Oct 12 '22 09:10

user1105951