How can I remove border bottom of UINavigationBar?

前提是你 提交于 2020-01-23 19:15:25

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!