What is the difference between Highlighted and Selected UIButton's State?
Solution 1:
The answers from 2012 aren't incorrect, but some might find the explanation in the UIControl docs to be…anemic. I personally find this explanation from the Collection View Programming Guide for iOS to be more helpful:
There is a subtle but important distinction between a cell’s highlighted state and its selected state. The highlighted state is a transitional state that you can use to apply visible highlights to the cell while the user’s finger is still touching the device. This state is set to
YES
only while the collection view is tracking touch events over the cell. When touch events stop, the highlighted state returns to the valueNO
. By contrast, the selected state changes only after a series of touch events has ended—specifically, when those touch events indicated that the user tried to select the cell.[…snip…]
Although this documentation is specifically for collection view cells, the explanation holds pretty well across the Cocoa Touch frameworks.
Solution 2:
According to the documentation:
Highlighted state of a control. A control enters this state when a touch enters and exits during tracking and when there is a touch up event.
and
Selected state of a control. For many controls, this state has no effect on behaviour or appearance. But other subclasses may have different appearance depending on their selected
state.
this is the pure difference between the states.