简体   繁体   中英

Transparent/translucent navigation bar with button items in Swift

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?

尝试这个:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM