简体   繁体   中英

Change the default color of top border line of UItabbar

Hello can anybody help me it would be greatly appreciated, I wanted to know how do you change the color of the default grey stroke on top of the UItab bar I also wanted the stroke to be 2px. I tried various methods of coding I place this code in the view controller:

self.tabBarController!.tabBar.layer.borderWidth = 0.50 self.tabBarController!.tabBar.layer.borderColor = UIColor.clearColor().CGColor

and it placed a stroke around the entire tab bar. I would like a 2px stroke on top with a custom rgb color of: red: 208, green: 28,blue: 28

Such as picture below:

enter image description here

Possible options:

  • Use a (stretchable) background image for the tabBar

  • It's not recommended playing with existing UI elements, but you may try simply adding a new sub view with the same width as the Tab Bar, 2 pixels high, the color you want as background, placed at (0,0)

您可以使用UITabBarshadowImage属性!

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