如何删除和添加回导航栏阴影?
How to remove and add back navigationBar shadow?
如果我删除导航栏阴影:
self.navigationController?.navigationBar.shadowImage = UIImage()
我怎样才能加回这个阴影?
//Extension
extension UINavigationBar {
func shouldRemoveShadow(_ value: Bool) -> Void {
if value {
self.setValue(true, forKey: "hidesShadow")
} else {
self.setValue(false, forKey: "hidesShadow")
}
}
}
//Use in view controller.
self.navigationController?.navigationBar.shouldRemoveShadow(true)
来自docs.
The default value is nil, which corresponds to the default shadow
image.
所以你设置就够了
self.navigationController?.navigationBar.shadowImage = nil
如果我删除导航栏阴影:
self.navigationController?.navigationBar.shadowImage = UIImage()
我怎样才能加回这个阴影?
//Extension
extension UINavigationBar {
func shouldRemoveShadow(_ value: Bool) -> Void {
if value {
self.setValue(true, forKey: "hidesShadow")
} else {
self.setValue(false, forKey: "hidesShadow")
}
}
}
//Use in view controller.
self.navigationController?.navigationBar.shouldRemoveShadow(true)
来自docs.
The default value is nil, which corresponds to the default shadow image.
所以你设置就够了
self.navigationController?.navigationBar.shadowImage = nil