How to remove border of the navigationBar in swift?

前端 未结 25 1830
执笔经年
执笔经年 2020-12-02 04:41

i\'ve been trying to remove the navigationBars border without luck. I\'ve researched and people seem to tell to set shadowImage and BackgroundImage to nil, but this does not

相关标签:
25条回答
  • 2020-12-02 05:36

    This is the way if you want to do it without changing the background color:

    // Remove the border ImageView from the NavigationBar background
    func hideBottomBorder() {
        for view in navigationBar.subviews.filter({ NSStringFromClass($0.dynamicType) == "_UINavigationBarBackground" }) as [UIView] {
            if let imageView = view.subviews.filter({ $0 is UIImageView }).first as? UIImageView {
                imageView.removeFromSuperview()
            }
        }
    }
    

    NOTE: This might crash on a production app. Apparently the NavigationBar doesn't like its view disappearing

    0 讨论(0)
提交回复
热议问题