0

I'm trying to get an almost transparent navigation bar. But I don't want the buttons on it to be transparent.

This is my code:

navigationController?.navigationBar.backgroundColor = UIColor.blackColor()
navigationController?.navigationBar.barTintColor = UIColor.blackColor()
navigationController?.navigationBar.translucent = true
navigationController?.navigationBar.alpha = 0.3

This does make it translucent but it also makes the buttons translucent/faded. How can I have a translucent bar but still have the buttons opaque?

Bista
  • 7,869
  • 3
  • 27
  • 55
Prabhu
  • 12,995
  • 33
  • 127
  • 210
  • see this http://stackoverflow.com/questions/19082963/how-to-make-completely-transparent-navigation-bar-in-ios-7 – Anbu.Karthik Aug 09 '16 at 04:17
  • this also http://stackoverflow.com/questions/13431976/visible-buttons-with-transparent-navigation-bar – Anbu.Karthik Aug 09 '16 at 04:17
  • @Anbu.Karthik thanks for the links, the second one seems to address my problem, but I don't know objective c, do you know of any swift examples? – Prabhu Aug 09 '16 at 05:05
  • sure i will do which one you need can you add, I will modfied to swift – Anbu.Karthik Aug 09 '16 at 05:08
  • @Anbu.Karthik actually I found a good enough answer here: http://stackoverflow.com/questions/2315862/make-uinavigationbar-transparent That still doesn't make it translucent, but it does make it fully transparent which works for me for now. Thanks for your help. – Prabhu Aug 09 '16 at 05:13

2 Answers2

0

Try this:

navigationController?.navigationBar.backgroundColor = UIColor.blackColor().colorWithAlphaComponent(0.3)
Lumialxk
  • 6,239
  • 6
  • 24
  • 47
  • Forget to say don't set alpha for `navigationBar` – Lumialxk Aug 09 '16 at 04:18
  • You sure this will keep the buttons still visible? – Prabhu Aug 09 '16 at 04:47
  • Yeah tried it, it keeps the buttons visible, but doesn't make the bar black. It just keeps it as the default color. Tint color is the one that seems to affect the color of the navigation bar. – Prabhu Aug 09 '16 at 05:03
-1
navigationController?.navigationBar.backgroundColor = UIColor.blackColor().colorWithAlphaComponent(0.3) 
navigationController?.navigationBar.barTintColor = UIColor.blackColor() 
navigationController?.navigationBar.translucent = true 
Yagnesh Dobariya
  • 2,241
  • 19
  • 29