System native is not the existence of this problem, because it is written, direct use can. However, due to the poor scalability of searchBar, we all need to rewrite searchBar to meet our own needs in actual use. Recently, some friends found that when clicking cancel, the background color of searchBar changed from light gray to dark gray, and then to light gray. What is the situation? You need to do the following when changing the layout:
[self.searchBar setShowsCancelButton:NO animated:YES];
Copy the code
Because when cancel cancel button, this phenomenon happened when loses focus, speculation is the focus and the focal point of no state is actually two view, cancel button control view, with a focus, didn’t hide this view leads to the middle switch display a moment, and the system primary is to do the processing.