iosswiftuikituisearchbar

With UISearchBar, will the microphone icon on the right "ever" become visible, and if so when?


Add a UISearchBar to your storyboard.

Note that this QA is only about UISearchBar and is not about UISearchController.

Confusingly there's a voice/mic icon on the right:

enter image description here

As far as I can tell, this actually never appears in a running app.

(Simulators or phones or pads, dev, test flight or production).

The problem is, I'm going to add another icon sitting there on top (typical X dismiss). So I'm concerned that under some circumstances, the voice/mic icon may become visible!


Solution

  • I don't know, any more than you do, why that icon is displayed in the storyboard when (as you rightly say) it doesn't appear in "real life". But as soon as you configure the search bar to show a specific right icon, your specification is obeyed and takes precedence over everything.

    For example, if you use the "X" button (to let the user empty out the contents of the search field), it will come and go coherently in accordance with the rules you specify, and the microphone, even if it did appear, would not override those rules.

    So I think you should just ignore the microphone icon in the storyboard and proceed normally.