What's the difference between UIControlStateHighlighted and UIControlStateSelected?

后端 未结 4 1394
没有蜡笔的小新
没有蜡笔的小新 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:38

    Highlighted is typically applied transiently when the control is being touched, selected is a more permanent state. Imagine a checkbox type button which dimmed while it was being touched - dimming is highlighted, ticked is selected, unticked is unselected.

    Typically you'd never set highlighted status manually as the system will be setting/unsettling it in response to touches, whereas selected is safer. This particularly applies to buttons.

提交回复
热议问题