Benobab
Benobab

Reputation: 428

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?

Upvotes: 0

Views: 2258

Answers (4)

Ganesh Manickam
Ganesh Manickam

Reputation: 2139

Add below lines in your viewWillAppear

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

Upvotes: 2

Riccardo Caroli
Riccardo Caroli

Reputation: 341

for parent in self.navigationController!.navigationBar.subviews {
        for childView in parent.subviews {
            if(childView is UIImageView) {
                childView.removeFromSuperview()
            }
        }
    }

Upvotes: 1

pixyzehn
pixyzehn

Reputation: 762

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
}

Upvotes: 2

Mehul Patel
Mehul Patel

Reputation: 23053

Modify AppDelegate file and add below code:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    // Override point for customization after application launch.

    // Change status bar color to white
    UIApplication.sharedApplication().statusBarStyle = UIStatusBarStyle.LightContent

    // To remove separtor line between navigation controller and view
    UINavigationBar.appearance().setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default)
    UINavigationBar.appearance().shadowImage = UIImage()
    return true
}

Upvotes: 2

Related Questions