I want to replace a default border in UINavigationBar
with shadow. Is there any way to achieve this? I have tried using the same approach as with adding shadow to UIView but it increases a height of my NavigationBar.
try this
self.navigationController.navigationBar.layer.shadowColor = UIColor.blackColor().CGColor
self.navigationController.navigationBar.layer.shadowOffset = CGSizeMake(2.0, 2.0)
self.navigationController.navigationBar.layer.shadowRadius = 4.0
self.navigationController.navigationBar.layer.shadowOpacity = 1.0
Swift 3
override func viewDidLoad() {
super.viewDidLoad()
self.navigationController?.navigationBar.layer.shadowColor = UIColor.black.cgColor
self.navigationController?.navigationBar.layer.shadowOffset = CGSize(width: 0.0, height: 2.0)
self.navigationController?.navigationBar.layer.shadowRadius = 4.0
self.navigationController?.navigationBar.layer.shadowOpacity = 1.0
self.navigationController?.navigationBar.layer.masksToBounds = false
}
output as
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With