封装:
封装按钮:1、有提示文字 —>UILable
2、并且可以点击 —> UIControl
UIButton:是一个按钮(系统已经把UIControl封装好了)。
里面可以放文字、图片,以及设置文字、图片相关的内容,同时也可以触发事件。
一、button的初始化有一个类方法 + (instancetype)buttonWithType:(UIButtonType)buttonType;
UIButtonTypeCustom = 0, // no button type
UIButtonTypeSystem //系统默认的样式
NS_ENUM_AVAILABLE_IOS(7_0), // standard system button
UIButtonTypeDetailDisclosure,// 显示详细信息的样式
UIButtonTypeInfoLight,//高亮
UIButtonTypeInfoDark,//灰暗
UIButtonTypeContactAdd,//+
UIButtonTypeRoundedRect = UIButtonTypeSystem, // Deprecated, use UIButtonTypeSystem instead
二、 UIControlState状态
UIControlStateNormal //普通状态
UIControlStateHighlighted//高亮状态
UIControlStateDisabled//取消禁用状态
UIControlStateSelected//选中状态
三、
titleForState:获得按钮某个状态的标题
titleColorForState:获得按钮某个状态的文字颜色
titleShadowColorForState:获得按钮某个状态的标题阴影颜色
imageForState:通过按钮的状态 找到按钮这个状态的图片
backgroundImageForState:获得按钮某个状态的背景图片