navigationController?.navigationBar.layer.shadowColor = ColorPalette.navigationBarShadowColor.cgColor
Set color according to traits mode.
class ColorPalette : NSObject {
static var navigationBarShadowColor: UIColor {
return UIColor { (traits) -> UIColor in
//dark: Black // light: grey16
return traits.userInterfaceStyle == .dark ?
UIColor.black : UIColor(hex: "dbdbdc")
}
}
}
4
Answers
we are using this and it is working but we want only one class we have to add this type of code like AppDelegate or some other classes .
Add this in AppDelegate
remove navigationBar shadow
if iOS 13
you can create a swift file add the below code in that file.
after that in your viewController add the below code in the viewWillAppear method