我已将这个波纹管代码应用于tabbar border
self.tabBarController?.tabBar.layer.borderWidth = 0.8 self.tabBarController?。tabBar.layer.borderColor = self.tabBarController?.tabBar.tintColor.cgColor
但使用此代码边框适用于所有方面,我只想在标签栏my tabbar that show tabbar border all side (top,left,right,bottom) 的顶部边框 i want tabbar like this sample image that show border only at top side 现在该怎么办? 感谢
答案 0 :(得分:1)
//First, remove the default top line and background
UITabBar.appearance().shadowImage = UIImage()
UITabBar.appearance().backgroundImage = UIImage()
//Then, add the custom top line view with custom color. And set the default background color of tabbar
let lineView = UIView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 1))
lineView.backgroundColor = UIColor.red
self.tabBarController?.tabBar.addSubview(lineView)
self.tabBarController?.tabBar.backgroundColor = UIColor.init(colorLiteralRed: 248.0/255.0, green: 248.0/255.0, blue: 248.0/255.0, alpha: 1.0)