【问题标题】:ios:set tabbar top border onlyios:仅设置标签栏顶部边框
【发布时间】:2017-04-12 08:44:51
【问题描述】:

我已将此波纹管代码应用于标签栏边框

self.tabBarController?.tabBar.layer.borderWidth = 0.8 self.tabBarController?.tabBar.layer.borderColor = self.tabBarController?.tabBar.tintColor.cgColor

但使用此代码边框适用于所有侧面,我只希望 tabbarmy 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 现在我该怎么办? 谢谢

【问题讨论】:

  • 这与我的问题无关@Lalitkumar 我找不到我的问题的答案

标签: ios uitabbarcontroller border


【解决方案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)

看起来像这样:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-12-29
    • 2019-07-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多