application
and reserved
are mostly markers. This is more understandable when viewing the objective-c documentation for them:
disabled :UIControlStateDisabled = 1 << 1
application :UIControlStateApplication = 0x00FF0000
reserved :UIControlStateReserved = 0xFF000000
, a UIControlState
, , UIControl
. 17 - 24
( 1 << 16
1 << 23
) , 25 - 32
( 1 << 24
1 << 31
) - .
, Apple / 16 , , 8 .
, . :
let myFlag = UIControlState(rawValue: 1 << 18)
class MyButton : UIButton {
var customFlags = myFlag
override var state: UIControlState {
get {
return [super.state, customFlags]
}
}
func disableCustom() {
customFlags.remove(myFlag)
}
}
let myButton = MyButton()
print(myButton.state.rawValue)
myButton.isEnabled = false
myButton.isSelected = true
print(myButton.state.rawValue)
myButton.disableCustom()
print(myButton.state.rawValue)