Socheat
Socheat

Reputation: 283

How can I remove border bottom of UINavigationBar?

I want to remove the bottom border from UINavigationBar, but I don't know how to remove it.

enter image description here

Upvotes: 1

Views: 4135

Answers (4)

doplumi
doplumi

Reputation: 3118

Actually, that is the shadow of the navigation bar.

To get rid of it, just set it to an empty image:

navigationController.navigationBar.shadowImage = UIImage()

Note: You must set it to an empty UIImage(); nil won't work for some reason.

Upvotes: 5

rockdaswift
rockdaswift

Reputation: 9983

For iOS 11 you can use the (deprecated) Black Translucent Navigation bar style with a custom bar tint.

Upvotes: 0

G. Veronika
G. Veronika

Reputation: 230

You need to set a custom shadow image to show instead of the default one. Note: a custom background image must also be set.

navController.navigationBar.barTintColor = .blue //set your color
navController.navigationBar.isTranslucent = false

navController.navigationBar.setBackgroundImage(UIImage(), for: .default)
navController.navigationBar.shadowImage = UIImage()

Upvotes: 2

Rushi trivedi
Rushi trivedi

Reputation: 747

you can do this

self.navigationController.navigationBar.layer.borderWidth = 0.0;

OR

you can give border color same as navigation bar background color

self.navigationController.navigationBar.layer.borderColor = [UIColor colorWithRed:<#(CGFloat)#> green:<#(CGFloat)#> blue:<#(CGFloat)#> alpha:<#(CGFloat)#>];

Upvotes: 0

Related Questions