ios控件 UIControl

时间:2023-12-10 14:22:26

《 UIControl》

1 处理用户事件的控件的基类,如UIButton,UISlider等
2 一般不直接实例化,而是使用他的子类
3 可以通过跟踪触摸事件来设置和获取控件状态,并且这些方法可以被子类继承
//添加一个事件
- (void)addTarget:(id)target action:(SEL)action forControlEvents:
(UIControlEvents)controlEvents;

//移除一个事件
- (void)removeTarget:(id)target action:(SEL)action forControlEvents:
(UIControlEvents)controlEvents;

 UIControlEventTouchDown //用户按下时触发
UIControlEventTouchDownRepeat //用户按下多次是触发
UIControlEventTouchDragInside //在控件内拖动是触发
UIControlEventTouchDragOutside //在控件外拖动时触发
UIControlEventTouchDragEnter //从控件外拖到控件内时触发
UIControlEventTouchDragExit //从控件内拖到控件外时触发
UIControlEventTouchUpInside //在控件内按下并松开时触发
UIControlEventTouchUpOutside //控件外松开时触发
UIControlEventTouchCancel //触摸被取消 设备上锁或电话打断时触发

=1<<0, =1<<1, =1<<2, =1<<3, =1<<4, =1<<5, =1<<6, =1<<7, =1<<8,

UIControlEventValueChanged //控件的值发生改变时触发
UIControlEventEditingDidBegin //文本控件开始编辑时触发
UIControlEventEditingChanged //文本控件中的文字被改变后触发
UIControlEventEditingDidEnd //文本控件结束编辑时触发
UIControlEventEditingDidEndOnExit = 1 << 19, //文本控件按回车时触发

UIControlEventAllTouchEvents = 0x00000FFF, //所有触摸事件

UIControlEventAllEditingEvents = 0x000F0000, UIControlEventApplicationReserved = 0x0F000000, UIControlEventSystemReserved = 0xF0000000, //所有文本编辑事件

UIControlEventAllEvents           = 0xFFFFFFFF//所有事件
UIControlStateNormal = 0, //正常状态
UIControlStateHighlighted = 1 << 0, //高亮状态
UIControlStateDisabled = 1 << 1,
//禁用状态
UIControlStateSelected = 1 << 2  //选中状态