如何更改Swift中iOS应用程序中每个标签的背景颜色,如图所示?
答案 0 :(得分:0)
这可以通过在每个标签上设置图像来实现:
let aryTabImages = ["home-icon.png","help-icon.png","photos-icon.png","cart-icon.png","search-icon.png"]
分配给每个标签栏项目:
for (index, item) in self.tabBarController!.tabBar.items!.enumerate() {
item.image = UIImage(named: aryTabImages.objectAtIndex(index) as! String)!.imageWithRenderingMode(.AlwaysOriginal)
item.selectedImage = UIImage(named: aryTabImages.objectAtIndex(index) as! String)!.imageWithRenderingMode(.AlwaysOriginal)
}
同时确保: