Select or deselect tab bar item

Hello Friends


I need work using tab bar item, but when I touch in a tab bar item the item change the color to blue, I need when I touch again, the item back to gray. To verify what the item is clicked I use this code:


func tabBar(tabBar: UITabBar!, didSelectItem item: UITabBarItem!) {
     switch item.tag  {
          case 0:
               //if item is selected, so back the gray color and deselect
               break
          case 1:
               //do something
               break
          default:
               //do something
               break
     }


Whats the line command tha I should put in my case function to select or deselect the item ? Or there is other way to do it?

Accepted Answer

A tab bar always has exactly one tab selected. You can only deselect a tab by selecting a different one.


You could probably mess with the selected image to make it the same as the deselected image, but that would be nonstandard UI and app review (and certainly users) might not like it.

Thanks by help


I get it.

Select or deselect tab bar item
 
 
Q