简体   繁体   English

如何删除并添加back navigationBar shadow?

[英]How to remove and add back navigationBar shadow?

if I remove navigationBar shadow: 如果我删除navigationBar阴影:

self.navigationController?.navigationBar.shadowImage = UIImage()

how I can add back this shadow? 我怎么能加回这个影子?

//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)

From the docs . 来自文档

The default value is nil, which corresponds to the default shadow image. 默认值为nil,对应于默认阴影图像。

So it should be enough that you set 所以你设置就足够了

self.navigationController?.navigationBar.shadowImage = nil

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM