我正在使用情节提要和 TabBarNavigation 控制器。选项卡的视图控制器嵌入在 NavigationController 中。我没有设置情节提要中第一个 TabBarItem 的图像。
- png 文件不显示。只显示了一个灰色方块,因此可能需要更改大小。
- 如果我选择第二个选项卡,第一个选项卡中的 png 文件将以正确的大小显示。
我无法通过文档弄清楚这一点。我该如何调整图像或我必须做什么?
var tabBarItem1 : UITabBarItem
var image1 = UIImage(named: "feed.png")
var image2 = UIImage(named: "feed_chosen.png")
tabBarItem1 = tabBar.items[0] as UITabBarItem
tabBarItem1.title = "Feed"
image1.drawInRect(CGRect(x: 0, y: 0, width: 40, height: 30))
tabBarItem1.image = image1
tabBarItem1.selectedImage = image2