2

I'm rather new to iOS development, and have been breaking my head for the last days on creating a translucent navigation bar with a custom tint.

My current status:

  • I've created a new project with a red view embedded in a navigation view, which is embedded in a tabbar.

  • In the red view, i position an image partially behind the navigation view, to prove that translucency is working. It works.

  • I change the bar tint color to white:

    [[UINavigationBar appearance] setBarTintColor: [UIColor whiteColor]];
    
  • The translucency is gone. The image doesn't shine trough anymore. So i tried:

    [[UINavigationBar appearance] setBarTintColor: [[UIColor whiteColor] colorWithAlphaComponent: 0.5]];
    
  • Still not working.

Any advice on how to fix this? Thanks.

JeroenJ
  • 41
  • 2

2 Answers2

0

If you want only the backround of the navigationBar to be translucent, you can try :

[(UIView*)[self.navigationController.navigationBar.subviews objectAtIndex:0] setAlpha:0.5f];

I found this here :https://stackoverflow.com/a/12389579/3626094

Otherwise, if you want the whole navigationBar translucent, including the buttons and title you can try:

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

I found this here :https://stackoverflow.com/a/6959527/3626094

Community
  • 1
  • 1
0

This worked for me:

[self.navigationController.navigationBar setTranslucent:NO];
self.navigationController.navigationBar.backgroundColor = [UIColor colorWithWhite:1 alpha:0.5];
Menno
  • 1,232
  • 12
  • 23