Search code examples
iosswiftuiviewuinavigationcontrolleruinavigationbar

Hide separtor line between navigationBar and Content


I would like to delete this junction (The line between the navigation bar and the ImageView Orange):

This line between the navigation bar and the ImageView Orange

Is there someone who knows how to do?


Solution

  • In my case, I implemented the following code.

    override func viewDidLoad() {
        super.viewDidLoad()
    
        if self.navigationController != nil {
            hideBorder(self.navigationController!.navigationBar)
        }
    }
    
    func hideBorder(view: UIView) -> Bool {
        if view.isKindOfClass(UIImageView.classForCoder()) && view.frame.size.height <= 1 {
            view.hidden = true
            return true
        }
    
        for sub in view.subviews {
            if hideBorder(sub as! UIView) {
                return true
            }
        }
        return false
    }