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

Posted iOS学习-文

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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)")
        }

 

以上是关于swift3.0中使用代码添加选中图片的主要内容,如果未能解决你的问题,请参考以下文章