如果我删除导航栏阴影:
self.navigationController?.navigationBar.shadowImage = UIImage()
我怎样才能把这个影子加回来?
来自文档。
默认值为nil,对应于默认阴影形象
所以设置就足够了
self.navigationController?.navigationBar.shadowImage = nil
//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)