What's the difference between UIControlStateHighlighted and UIControlStateSelected?

后端 未结 4 1390
没有蜡笔的小新
没有蜡笔的小新 2021-02-05 19:21

I am trying to set a state for UIButton.

But i don\'t know the difference between the UIControlStateHighlighted and UIControlStateSelected.

4条回答
  •  伪装坚强ぢ
    2021-02-05 19:55

    From the official doc:

    UIControlStateHighlighted 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. You can retrieve and set this value through the highlighted property.

    UIControlStateSelected Selected state of a control. For many controls, this state has no effect on behavior or appearance. But other subclasses (for example, the UISegmentedControl class) may have different appearance depending on their selected state. You can retrieve and set this value through the selected property.

    Your button get highlighted in reaction of a touch event. It could then be on a selected state within a group (for segmented control).

提交回复
热议问题