Make transparent navigation bar relative to image below in iOS 8.1

I am trying to adjust the transparency of my navigation bar relative to the image below this, something like the following image:

enter image description here

I tried the solution in the transparent ios navigation bar , but I do not get the above result, I only get the icon on the left, but without any color in the navigation bar, completely transparent. But if I set the background color, the transparency will disappear altogether.

Is there any way to set the color in the navigation bar and make it transparent?

Thanks in advance.

+7
swift ipad
Dec 30 '15 at 16:26
source share
4 answers

just checked sim 8.1 and got a very similar result to your image

let bar:UINavigationBar! = self.navigationController?.navigationBar bar.setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default) bar.shadowImage = UIImage() bar.backgroundColor = UIColor(red: 0.0, green: 0.3, blue: 0.5, alpha: 0.3) 

The main point here is the background color with alpha.

Check the attached image, maybe I missed something?

enter image description here

+30
Jan 05 '15 at 19:48
source share

To set this style worldwide, use the UIAppearance API. In the AppDelegate application:didFinishLaunchingWithOptions: add the following code:

 // Sets background to a blank/empty image UINavigationBar.appearance().setBackgroundImage(UIImage(), forBarMetrics: .Default) // Sets shadow (line below the bar) to a blank image UINavigationBar.appearance().shadowImage = UIImage() // Sets the translucent background color UINavigationBar.appearance().backgroundColor = UIColor(red: 0.0, green: 0.3, blue: 0.5, alpha: 0.3) // Set translucent. (Default value is already true, so this can be removed if desired.) UINavigationBar.appearance().translucent = true 
+12
Jan 05 '15 at 20:16
source share

Have you tried setting the navigationBar alpha property? In the root view controller, the navigation controller ...

 [self.navigationController.navigationBar setBackgroundColor:[UIColor greenColor]]; [self.navigationController.navigationBar setAlpha:0.3f]; 
0
Jan 05 '15 at 19:39
source share
 self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default) self.navigationController?.navigationBar.shadowImage = UIImage() self.navigationController?.navigationBar.backgroundColor = UIColor.clear self.navigationController?.navigationBar.isTranslucent = true 

If the above code does not work, set the edgeForExtendedLayout parameter to all.

 self.edgesForExtendedLayout = .all 
0
Dec 03 '18 at 8:22
source share



All Articles