Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Transparent Navbar
call in viewDidLoad
setUpNavBar(bottomBorderColor: .white, opacity: 0.4, height: 1)
func setUpNavBar(bottomBorderColor:UIColor,opacity:Float,height:CGFloat){
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
let navLabel = UILabel(frame:
navLabel.backgroundColor = UIColor.clear
navLabel.font = UIFont.systemFont(ofSize: 18)
navLabel.textAlignment =
navLabel.textColor = UIColor.white
navLabel.text = "Tranparent Navbar"
self.navigationItem.titleView = navLabel
let navBottomBorder = UIView(frame: CGRect(x: 0, y: self.navigationController!.navigationBar.frame.size.height - 1, width: self.view.frame.size.width, height: height))
navBottomBorder.backgroundColor = bottomBorderColor
navBottomBorder.layer.opacity = opacity
navBottomBorder.isOpaque = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment