I am trying to apply a custom drop shadow to NavigationView with White Background.
I did try with UINavigationBar.appearance() but it didn't work in the SwiftUI Views.

I am looking for this kind of shadow with custom color and radius.
Has anyone faced any issue in it or done it before.
Any help will be appreciated.
I'm not sure why UINavigationBarAppearance wasn't working for you.
I was able to do this for SwiftUI NavigationViews using the UINavigationBarAppearance() configurations, like this:
let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.shadowColor = nil // or a custom tint color
appearance.shadowImage = UIImage(named: "shadow")
UINavigationBar.appearance().standardAppearance = appearance
Here's a sample image you could use to get something similar to what your image shows. To apply a custom tint, use the shadowColor property above. To get a custom radius, you'd need to modify the shadow image.

Here's an example of what the SwiftUI NavigationView looks like when I do this.

Note that the UINavigationBarAppearance settings must be applied before the NavigationView is created. Otherwise, the settings won't take effect.
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