swift3.0中使用代码添加选中图片

        private lazy var imageNames = ["tabbar_home", "tabbar_message_center", "", "tabbar_discover", "tabbar_profile"]
        // 遍历所有的item
        for i in 0..<tabBar.items!.count {
            // 2. 获取item
            let item = tabBar.items![i]
            
            // 3. 如果下标为2,则该item不可以和用户交互
            if i == 2 {
                item.isEnabled = false
                continue
            }
            // 4. 设置其他item选中时候的图片
            item.selectedImage = UIImage(named: imageNames[i] + "_highlighted")
            print("\(item.selectedImage)")
        }

 

posted on 2016-10-21 10:28  iOS学习-文  阅读(196)  评论(0编辑  收藏  举报

导航