/ UINavigationBar

隐藏导航栏底部直线

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 let view = view as? UIImageView where view.bounds.height <= 1.0 {
            return view
        }
	        if let subviews = view.subviews as? [UIView] {
	            for subview in subviews {
	                if let imageView = hairlineImageViewInNavigationBar(subview) {
	                    return imageView
	                }
	            }
	        }
	        return nil
	    }
	}