【发布时间】:2015-01-11 19:06:28
【问题描述】:
我一直在尝试更改 UITabBar 上的选定图像。我已按照其他 Stackoverflow 问题中列出的程序进行操作,但似乎没有任何效果。
我尝试通过用户定义的运行时属性部分设置图像,并尝试将以下内容添加到 AppDelegate.swift:
var tabBarController = self.window!.rootViewController as UITabBarController
let tabItems = tabBarController.tabBar.items as [UITabBarItem]
var selectedImage0 = UIImage(named:"NewsfeedTabSelected")
selectedImage0?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
tabItems[0].selectedImage = selectedImage0
这不会产生任何结果。我做了一个 println(tabItems[0].title) 并且输出了正确的标题,所以我知道对 TabBarItem 的引用正在工作。
有什么想法吗?
【问题讨论】:
-
您是否尝试过在情节提要中使用选定的图像?
标签: ios swift uitabbaritem