简体   繁体   中英

Change color of bottom border Navigation Bar iOS

My navigation bar is clear and I need to keep the bottom bar of the border white, I tried to use this code:

[self.navigationController.navigationBar.layer setBorderWidth:2.0];
[self.navigationController.navigationBar.layer setBorderColor:[[UIColor whiteColor] CGColor]];

But this makes the entire border white on all four edges white, how can I only change the bottom border?

I thought about adding an image at the very bottom to replicate the bar but I was hoping there was an easier way to do this.

Give the navigation bar a background image that is mostly clear but whose bottom edge (2 pixels or whatever) is white. It's easy to construct this image in code so there's really no need to wish for "an easier way".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM