alexxjk alexxjk - 1 year ago 133
Swift Question

How to add shadow to Navigation Bar instead of default border

I want to replace a default border in

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.

Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download