objective-cios7uinavigationbarnavigationbartranslucency

How to set transparency of translucent navigation bar in iOS7?


I searched and tried as below, but doesn't work. In fact, event set translucent = YES can't make the navigation bar translucent.Does anyone know?

self.navigationController.navigationBar.tintColor = [UIColor blueColor];
self.navigationController.navigationBar.alpha = 0.7f;
self.navigationController.navigationBar.translucent = YES;

Solution

  • It's late, but if anyone need the answer here it is.

    If you want transparency in all navigationBar than write following lines in your AppDelegate's -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions method:

    ## Objective C ##

    [[UINavigationBar appearance] setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
    [[UINavigationBar appearance] setShadowImage:[UIImage new]];
    [[UINavigationBar appearance] setTranslucent:YES];
    

    ## Swift ##

    UINavigationBar.appearance().setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default)
    UINavigationBar.appearance().shadowImage = UIImage()
    UINavigationBar.appearance().translucent = true
    

    For transparency in particular view, check this answer.