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)") }
时间: 2024-10-14 05:54:11