嘿,我想快速更改我的中心选项卡栏项目的背景颜色,例如 instagram,任何人都知道它是如何工作的。我用谷歌搜索但找不到任何有用的答案。
最佳答案
您可以使用以下代码:
// Add background color to middle tabBarItem
let itemIndex = 2
let bgColor = UIColor(red: 0.08, green: 0.726, blue: 0.702, alpha: 1.0)
let itemWidth = tabBar.frame.width / CGFloat(tabBar.items!.count)
let bgView = UIView(frame: CGRectMake(itemWidth * itemIndex, 0, itemWidth, tabBar.frame.height))
bgView.backgroundColor = bgColor
tabBar.insertSubview(bgView, atIndex: 0)
作为引用,您可以查看这些 Stackoverflow 帖子:
关于ios - 编辑特定选项卡栏项目的背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32351287/