问题
I want to remove the bottom border from UINavigationBar, but I don't know how to remove it.
回答1:
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.
回答2:
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()
回答3:
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)#>];
回答4:
For iOS 11 you can use the (deprecated) Black Translucent Navigation bar style with a custom bar tint.
来源:https://stackoverflow.com/questions/34942141/how-can-i-remove-border-bottom-of-uinavigationbar