How to remove border in navigationBar in swift?

To remove the border from a navigation bar in swift, we just need to add a few lines of code. Let’s see how the navigation bar looks when we run it without changing anything.

Now let’s try to hide the line/ border shown in the above result.

The navigation bar has two things that give it the default view of a grey shadow along with bottom line as shown above. One is the background image, and the other is the shadow image.

First, we’ll hide the shadow image, by setting it to empty image and see how it looks.

In your viewDidLoad add the following code −

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

When we run the above code, we get the following result −

Now, we’ll also hide the background image just like shadow image, and it will look like the navigation bar has disappeared.

karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know