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)") }