Created
December 4, 2016 20:00
-
-
Save agibson73/87a44defc2f8e9088aa2970fecd7e8e9 to your computer and use it in GitHub Desktop.
Transparent Navbar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: CGRect.zero) | |
navLabel.backgroundColor = UIColor.clear | |
navLabel.font = UIFont.systemFont(ofSize: 18) | |
navLabel.textAlignment = NSTextAlignment.center | |
navLabel.textColor = UIColor.white | |
navLabel.text = "Tranparent Navbar" | |
navLabel.sizeToFit() | |
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 | |
navigationController?.navigationBar.addSubview(navBottomBorder) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment