NS_CLASS_AVAILABLE_IOS(2_0) @interface UIControl : UIView
@property(nonatomic,getter=isEnabled) BOOL enabled;
// default is YES. if NO, ignores touch events and subclasses may draw differently
Enabled 是UIControl的属性,父类是UIView,这个属性会对控件的视觉有影响 ,当为NO时 控件默认显示灰色,触摸事件会被忽略,通常是禁用控制的首选
NS_CLASS_AVAILABLE_IOS(2_0) @interface UIView : UIResponder
@property(nonatomic,getter=isUserInteractionEnabled) BOOL userInteractionEnabled;
// default is YES. if set to NO, user events (touch, keys) are ignored and removed from the event queue.
UserInteractionEnabled是UIView的属性,父类是UIResponder,触摸事件会被忽略并且会从响应链(响应队列)中移除
总结:如果控件有enabled 属性那就优先使用,因为它更直观,没有在使用UserInteractionEnabled
网友评论