How to make completely transparent navigation bar in iOS 7

ios 11 transparent navigation bar
how to make the navigation bar transparent
ios transparent status bar
transparent navigation bar swift5
uiimagepickercontroller navigation bar color ios 13
make navigation bar opaque swift
navigation bar height ios 13
xcode 11 navigation bar not showing

I want the UINavigationBar in my app to be completely transparent and flush with the viewcontroller directly under it. However, the only code I could find makes it translucent but not transparent. I know this can be done in iOS 7 because it is used in the notes app. My question is, what is the code they used to do it?

From this answer

[self.navigationController.navigationBar setBackgroundImage:[UIImage new]
                     forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.shadowImage = [UIImage new];
self.navigationController.navigationBar.translucent = YES;
self.navigationController.view.backgroundColor = [UIColor clearColor];
self.navigationController.navigationBar.backgroundColor = [UIColor clearColor];

Also, as suggested by Josh in the comments, to put the bar back to default:

[self.navigationController.navigationBar setBackgroundImage:nil
                     forBarMetrics:UIBarMetricsDefault];

How to create transparent Status Bar and Navigation Bar in iOS?, The status bar is now transparent, that means the navigation bar behind it shows through. So if you're still using older versions of Xcode, make sure you upgrade to Xcode 5 As you can see, the navigation bar in iOS 7 is by default intertwined with the status bar. Great article, full of useful little tips. iOS7  Like many of you, I have been very busy upgrading my apps to make them fit for iOS 7. The latest version of iOS introduces lots of visual changes. From a developer’s perspective, the navigation bar and status bar are two noticeable changes that need to cater. The status bar is now transparent, that means the navigation bar behind it shows

For Swift3 and Swift4

self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
self.navigationController?.navigationBar.shadowImage = UIImage()
self.navigationController?.navigationBar.isTranslucent = true

For Swift2.2

 self.navigationController?.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: .Default)
 self.navigationController?.navigationBar.shadowImage = UIImage()
 self.navigationController?.navigationBar.translucent = true

For Objective-C

[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.shadowImage = [UIImage new];
self.navigationController.navigationBar.translucent = YES;

iOS 7 Programming Tips: Customize Navigation Bar and Status Bar, I want the UINavigationBar in my app to be completely transparent and flush with the viewcontroller directly under it. However, the only code I could find makes it  show 7 more comments. 29. In iOS5 you can do this to make the navigation bar transparent: nav.navigationBar.translucent = YES; // Setting this slides the view up, underneath the nav bar (otherwise it'll appear black) const float colorMask[6] = {222, 255, 222, 255, 222, 255}; UIImage *img = [ [UIImage alloc] init]; UIImage *maskedImage = [UIImage imageWithCGImage: CGImageCreateWithMaskingColors(img.CGImage, colorMask)]; [nav.navigationBar setBackgroundImage:maskedImage

Self contained solution as an Objective-C Category:

UINavigationController+TransparentNavigationController.h

@interface UINavigationController (TransparentNavigationController)
- (void)presentTransparentNavigationBar;
- (void)hideTransparentNavigationBar;
@end

UINavigationController+TransparentNavigationController.m

#import "UINavigationController+TransparentNavigationController.h"

@implementation UINavigationController (TransparentNavigationController)

- (void)presentTransparentNavigationBar
{
  [self.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
  [self.navigationBar setTranslucent:YES];
  [self.navigationBar setShadowImage:[UIImage new]];
  [self setNavigationBarHidden:NO animated:YES];
}

- (void)hideTransparentNavigationBar
{
  [self setNavigationBarHidden:YES animated:NO];
  [self.navigationBar setBackgroundImage:[[UINavigationBar appearance] backgroundImageForBarMetrics:UIBarMetricsDefault] forBarMetrics:UIBarMetricsDefault];
  [self.navigationBar setTranslucent:[[UINavigationBar appearance] isTranslucent]];
  [self.navigationBar setShadowImage:[[UINavigationBar appearance] shadowImage]];
}

@end

Now, you can import the category in your UIViewController and call the methods on your navigation controller - for example:

#import "UINavigationController+TransparentNavigationController.h"

- (void)viewWillAppear:(BOOL)animated
{
  [super viewWillAppear:animated];
  [self.navigationController presentTransparentNavigationBar];
}

- (void)viewWillDisappear:(BOOL)animated
{
  [super viewWillDisappear:animated];
  [self.navigationController hideTransparentNavigationBar];
}

And a similar solution in Swift:

import Foundation
import UIKit

extension UINavigationController {

  public func presentTransparentNavigationBar() {
    navigationBar.setBackgroundImage(UIImage(), forBarMetrics:UIBarMetrics.Default)
    navigationBar.translucent = true
    navigationBar.shadowImage = UIImage()
    setNavigationBarHidden(false, animated:true)
  }

  public func hideTransparentNavigationBar() {
    setNavigationBarHidden(true, animated:false)
    navigationBar.setBackgroundImage(UINavigationBar.appearance().backgroundImageForBarMetrics(UIBarMetrics.Default), forBarMetrics:UIBarMetrics.Default)
    navigationBar.translucent = UINavigationBar.appearance().translucent
    navigationBar.shadowImage = UINavigationBar.appearance().shadowImage
  }
}

cocoa touch How to make completely transparent navigation bar in , cocoa touch How to make completely transparent navigation bar in iOS 7? self.​navigationController?.navigationBar.setBackgroundImage(UIImage()  Setting translucent to YES on the navigation bar does the trick, due to a behavior discussed in the UINavigationBar documentation. I'll report here the relevant fragment: If you set this property to YES on a navigation bar with an opaque custom background image, the navigation bar will apply a system opacity less than 1.0 to the image.

Alan forgot one line

self.navigationController.navigationBar.backgroundColor = [UIColor clearColor];

So I have:

[self.navigationController.navigationBar setTranslucent:YES];
self.navigationController.view.backgroundColor = [UIColor clearColor];
[self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.shadowImage = [[UIImage alloc] init];
self.navigationController.navigationBar.backgroundColor = [UIColor clearColor];

Transparent Navigation Bar but Keep iOS Blur, In iOS 7 navigation bars have a blur effect for content that is scrolled underneath. They answer how to get a completely transparent navbar or get a certain  And as I said, make sure the view below goes under the navigation bar, otherwise you won't see any content shine through the bar. If you are using Interface Builder, you can drag and align the top edge of that view with the upper edge of the screen.

@Zorayr's great answer revised to Swift 3 :

import Foundation
import UIKit

extension UINavigationController {

    public func presentTransparentNavigationBar() {
        navigationBar.setBackgroundImage(UIImage(), for:.default)
        navigationBar.isTranslucent = true
        navigationBar.shadowImage = UIImage()
        setNavigationBarHidden(false, animated:true)
    }

    public func hideTransparentNavigationBar() {
        setNavigationBarHidden(true, animated:false)
        navigationBar.setBackgroundImage(UINavigationBar.appearance().backgroundImage(for: UIBarMetrics.default), for:.default)
        navigationBar.isTranslucent = UINavigationBar.appearance().isTranslucent
        navigationBar.shadowImage = UINavigationBar.appearance().shadowImage
    }
}

Make navigation bar transparent swift 5, That changed with the introduction of iOS 7, which had a transparent status bar make the nav bar transparent, drive your content full-screen, and find a 28 Oct  Change the status bar style via : In your Info.plist you need to define View controller-based status bar appearance to any value. UIApplication.shared.statusBarStyle = .lightContent If you want to hide the status bar: UIApplication.shared.isStatusBarHidden = true Getting this output by light content and by transparent navigation.

Navbar Apps, Tired of your boring Navigation Bar? Make it awesome! Turn it blue, make it red - anything you want. Select cool image as background or match color  Alternatively, you can do it from the Settings app by choosing "Wallpaper," then "Choose a New Wallpaper." Select the "Camera Roll" album, then the picture you downloaded, and make sure "Still" is preselected. Next, tap "Set," and select "Set Home Screen."

Transparent Navigation Bar iOS, If you want the navigation bar to be fully transparent at all times, just remove the hex value in Customizer > Colors > Primary Navigation >  You can now make the system bars partially translucent with new themes, Theme.Holo.NoActionBar.TranslucentDecor and Theme.Holo.Light.NoActionBar.TranslucentDecor. By enabling translucent system bars, your layout will fill the area behind the system bars, so you must also enable fitsSystemWindows for the portion of your layout that should not be covered by the system bars.

How do I make navigation bar transparent?, je veux que la barre D'Uinavigationde mon application soit complètement transparente et affleure avec le viewcontroller directement en dessous. Cependant, le seul code que j'ai pu trouver le rend translucide mais pas transparent. Je sais que cela peut être fait dans iOS 7 car il est utilisé dans l'application notes.

Comments
  • Also make sure you dont have self.edgesForExtendedLayout = UIRectEdgeNone;
  • Is there a way to reverse this?
  • @Zorayr [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault]; will put the bar back to default.
  • Is there any way to toggle navigation bar's transparency animated using this method?
  • I implement this on scrollViewDidScroll and there's a jump. How to fix?
  • Thanks this is an easy way to set the navigation bar to totally transparent
  • How can i show it again (for example if ill want to make it transparent only in 1 view in an NavigationController?) - can i reset it to my default values?
  • hideTransparentNavigationBar() should reset it back.
  • Calling present/hide methods in viewWillAppear/disappear cause a bad transition animation between the two differents navigation bar! You can see it very well by doing the swipe gesture (from left to right) in the pushedViewController
  • Try calling it in viewDidHide of the parent view controller.
  • Black background is shown on iOS 11 when using LargeTitle when hiding transparent navbar