我正在使用 Xcode 开发一个应用程序。我的标签栏上目前有三个 tabBarItems。我希望中间的一张是用户选择的图片。我在一个变量中有所需的图片,我设置了 tabbar.swift 来放入代码。我只需要将图像设置为具有正确大小的变量图像(并使图片显示为一个圆圈)和标题字符串的名称。 在这方面的任何帮助将不胜感激。谢谢
最佳答案
试试这段代码。
self.tabBarController?.tabBar.items![0].image = UIImage(named: "your image name")
// items![0] index of your tab bar item.items![0] means tabbar first item
self.tabBarController?.tabBar.items![0].selectedImage = UIImage(named: "your image name")
关于ios - 以编程方式快速更改标签栏项目图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39358782/