1.模块继承关系:

1.UIButton        ->UIControl  -> UIView

2.UILabel          ->UIview

3.UIImageView  ->UIView

4.UITextField    ->UIControl

对于@selector为什么可以监听:@selector将监听方法注册到”运行循环“,”运行循环“当按钮点击后,通知视图控制器执行@selector的方法

UIControl的剖析:

 /______________________________________________________

 NS_CLASS_AVAILABLE_IOS(2_0) @interface UIControl : UIView

 //1.1设置控件的状态
启用 禁用:一个按钮可不可以点击
@property(nonatomic,getter=isEnabled) BOOL enabled; // default is YES. if NO, ignores touch events and subclasses may draw differently
选中 不选中:
@property(nonatomic,getter=isSelected) BOOL selected; // default is NO may be used by some subclasses or by application
高亮或者不高亮
@property(nonatomic,getter=isHighlighted) BOOL highlighted; // default is NO. this gets set/cleared automatically when touch enters/exits during tracking and cleared on up

1.2设置控件内容的布局
垂直居中方向
9 @property(nonatomic) UIControlContentVerticalAlignment contentVerticalAlignment; // how to position content vertically inside control. default is center
水平居中方向
@property(nonatomic) UIControlContentHorizontalAlignment contentHorizontalAlignment; // how to position content hozontally inside control. default is center @property(nonatomic,readonly) UIControlState state; // could be more than one state (e.g. disabled|selected). synthesized from other flags.
@property(nonatomic,readonly,getter=isTracking) BOOL tracking;
@property(nonatomic,readonly,getter=isTouchInside) BOOL touchInside; // valid during tracking only - (BOOL)beginTrackingWithTouch:(UITouch *)touch withEvent:(nullable UIEvent *)event;
- (BOOL)continueTrackingWithTouch:(UITouch *)touch withEvent:(nullable UIEvent *)event;
- (void)endTrackingWithTouch:(nullable UITouch *)touch withEvent:(nullable UIEvent *)event; // touch is sometimes nil if cancelTracking calls through to this.
- (void)cancelTrackingWithEvent:(nullable UIEvent *)event; // event may be nil if cancelled for non-event reasons, e.g. removed from window // add target/action for particular event. you can call this multiple times and you can specify multiple target/actions for a particular event.
// passing in nil as the target goes up the responder chain. The action may optionally include the sender and the event in that order
// the action cannot be NULL. Note that the target is not retained.
添加或者删除监听方法 - (void)addTarget:(nullable id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents; // remove the target/action for a set of events. pass in NULL for the action to remove all actions for that target
- (void)removeTarget:(nullable id)target action:(nullable SEL)action forControlEvents:(UIControlEvents)controlEvents; // get info about target & actions. this makes it possible to enumerate all target/actions by checking for each event kind
- (NSSet *)allTargets; // set may include NSNull to indicate at least one nil target
- (UIControlEvents)allControlEvents; // list of all events that have at least one action
- (nullable NSArray<NSString *> *)actionsForTarget:(nullable id)target forControlEvent:(UIControlEvents)controlEvent; // single event. returns NSArray of NSString selector names. returns nil if none // send the action. the first method is called for the event and is a point at which you can observe or override behavior. it is called repeately by the second.
- (void)sendAction:(SEL)action to:(nullable id)target forEvent:(nullable UIEvent *)event;
- (void)sendActionsForControlEvents:(UIControlEvents)controlEvents; // send all actions associated with events @end NS_ASSUME_NONNULL_END

最新文章

  1. 用NPOI从DataBase到Excel &#39;2
  2. 基于Simple Image Statistics(简单图像统计,SIS)的图像二值化算法。
  3. TYVJ1982 武器分配
  4. Ajax 局部刷新
  5. Delphi中编辑word
  6. shell判断一个变量是否为空
  7. 微软下一代云环境Web开发框架ASP.NET vNext预览
  8. [Oracle] Data Guard 系列(5) - 创建逻辑备库
  9. 利用Ring Buffer在SQL Server 2008中进行连接故障排除
  10. 2620: [Usaco2012 Mar]Haybale Restacking
  11. 移动端和pc端事件绑定方式以及取消浏览器默认样式和取消冒泡
  12. 内核对象kobject和sysfs(3)——kobj分析
  13. CTF---密码学入门第五题 传统知识+古典密码
  14. Maven学习 六 pom.xml文件
  15. 批处理命令学习笔记——Start命令
  16. Php面向对象 – 类常量
  17. TX失败策略2
  18. GraphQL返回分页对象
  19. pymongo 学习
  20. SSAS中CUBE的多对多关系既可以出现在中间事实表上也可以出现在中间维度表上

热门文章

  1. POJ-3259 Wormholes---SPFA判断有无负环
  2. Git的本地仓库与GitHub的远程仓库
  3. Vue练手项目(包含typescript版本)
  4. 【linux之crontab,启动】
  5. 微信小程序之Todo
  6. Canvas - 时钟绘制
  7. servlet与ajax数据交换(json格式)
  8. Mysql之数据类型(胖胖老师)
  9. day 1——字典树练习
  10. [Awson原创]洪水(flood)