Kha*_*inn 0 uitabbarcontroller uistoryboard swift ios8
我试图在iOS 8的UIStoryboard中使用swift创建自定义标签栏控制器(objective-c也没关系).所以,我计划使用这段代码.
let item0: UITabBarItem = UITabBarController().tabBar.items[0] as UITabBarItem
item0.setFinishedSelectedImage(selectedImage0, withFinishedUnselectedImage: unselectedImage0)
Run Code Online (Sandbox Code Playgroud)
但是,问题是setFinishedSelectedImage不再支持,我看到了这个错误.我该如何实施?
从iOS 7及更早版本开始不推荐使用的API在Swift中不可用
我没有Xcode 6来测试这个,所以CODE没有测试但我希望在Swift中有类似的东西:
var selectedImage0 : UIImage = UIImage(named:"selectedImage0.png").imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
self.navigationController.tabBarItem.selectedImage = selectedImage0
Run Code Online (Sandbox Code Playgroud)
为了得到第一个tabBarItem我会期望类似于以下的东西,但再次代码没有测试:
// self.yourTabBarController is an IBOutlet to your UITabBar controller
let tabBar = self.yourTabBarController.tabBar
// UITabBar Items are an array in order (0 is the first item)
let tabItems = tabBar.items as [UITabBarItem]
tabItems[0].title = "First"
tabItems[0].selectedImage = selectedImage0
tabItems[1].title = "Second"
tabItems[1].selectedImage = selectedImage1
/*
etc...
*/
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4235 次 |
| 最近记录: |