I'm trying to add a drop shadow to my navigationbar. The code looks like this:
UINavigationBar.appearance().barStyle = .black
UINavigationBar.appearance().barTintColor = UIColor(white: 155/255,
alpha: 1.0)
UINavigationBar.appearance().isTranslucent = false
UINavigationBar.appearance().layer.shadowOffset = CGSize(width: 0, height: 4)
UINavigationBar.appearance().layer.shadowRadius = 4.0
UINavigationBar.appearance().layer.shadowColor = UIColor.black.cgColor
UINavigationBar.appearance().layer.shadowOpacity = 0.4
UINavigationBar.appearance().layer.masksToBounds = false
UINavigationBar.appearance().layer.shouldRasterize = true
But it does not work. Why is it not working and what am I missing? I don't want to extend or subclass the NavigationBar to do this.
EDIT: I figured out that the
UINavigationBar.appearance().layer.bounds
returns wrong values so probably thats the case but does someone know why?