您好,我正在以编程方式创建选项卡栏,在我的功能中,需要选择填充有自定义颜色的选项卡,到目前为止,我已经使用以下代码和以下输出(参见屏幕截图)实现了此目的。
tabBarController.tabBar.selectionIndicatorImage = UIImage.imageWithColor(color: colors.AppSkyBlue, size: tabBarItemSize).resizableImage(withCapInsets: UIEdgeInsets(top: 1, left: 1, bottom: 1, right: 1), resizingMode: .stretch)
清楚地看到所选选项卡周围的空白,我应该从所有侧面删除它。任何帮助将不胜感激。
答案 0 :(得分:1)
您可以简单地在UITabBar顶部添加一个子视图,并使bg颜色与选项卡栏的颜色相同-以便与之融合
var lineView = UIView(frame: CGRect(x: 0, y: 0, width:tabBarController.tabBar.frame.size.width, height: 1))
lineView.backgroundColor = UIColor.grey
tabBarController.tabBar.addSubview(lineView)
这是选项之一。