转载

隐藏导航栏底部直线

NavigationBar 的底部有一个 ShadowImage 作为阴影,对其隐藏或者显示,可以利用以下的扩展来实现

 extension UINavigationBar {   func hideBottomHairline() {    let navigationBarImageView = hairlineImageViewInNavigationBar(self)    navigationBarImageView?.hidden = true   }   func showBottomHairline() {    let navigationBarImageView = hairlineImageViewInNavigationBar(self)    navigationBarImageView?.hidden = false   }   private func hairlineImageViewInNavigationBar(view: UIView) -> UIImageView? {    if view.isKindOfClass(UIImageView) && view.bounds.height <= 1.0 {     return (view as! UIImageView)    }    if let subviews = view.subviews as? [UIView] {     for subview in subviews {      if let imageView = hairlineImageViewInNavigationBar(subview) {       return imageView      }     }    }    return nil   }  }  
正文到此结束
Loading...