天天看点

UIButton 方法以及属性

属性

contentEdgeInsets

//设置内边距

titleEdgeInsets   

//设置titleLabel的边界

reversesTitleShadowWhenHighLighted

//设置高亮时是否改变阴影的BOOL值

imageEdgeInsets

//设置imageView的边界

adjustsImageWhenHighLighted​                                                                                     

//按下button时,是否产生变化

adjustsImageWhenDisabled

//设置button不可用时是否产生变化

showsTouchWhenHighlighted

//设置button被点按时是否发光

tintColor

//该控件上的渲染颜色

buttonType

//按钮的样式

UIButtonTypeCustom = 0

//无样式

UIButtonTypeSystem

//设置为系统样式

UIButtonTypeDetailDisclosure

//详细信息样式 (被动加上一个感叹号)

UIButtonTypeInfoLight

//同上

UIButtonTypeInfoDark

//同上

UIButtonTypeContactAdd

//显示加号

UIButtonTypeRoundRect

//(被弃用的)请使用UIButtonTypeSystem样式

currentTitle

//当前应该显示的标题 (只读)

currentTitleColor

//当前应该显示的标题颜色 (只读)

currentTitleShadowColor

//当前应该显示的标题阴影颜色 (只读)

currentImage

//当前应该显示的图片 (只读)

currentBackgroundImage

//当前应该显示的背景图片 (只读)

currentAttributedTitle

//当前应该显示的带有属性的标题 (只读)

titleLabel

//按钮中显示的label显示的内容 (只读)  此属性与currentTitle有很大不同

imageView

//按钮中显示的imageView (只读) 此属性与currentImage有很大不同

实例方法

setTitle: forState:   //设置button 某状态下 的标题

setTitleColor: forState:

//设置button 某状态下的标题颜色

setTitleShadowColor: forState:

//设置某状态下标题的阴影颜色

setImage: forState:

//设置某状态下的图片

setBackgroundImage: forState:

//设置某状态下的背景图片

setAttributedTitle: forState:

//设置带有属性的title

titleForState:

//返回指定状态下的title(NSString *)注意,仅返回无属性的标题

titleColorForState:

//返回指定状态下title的颜色,(UIColor *)

titleShadowColorForState:

//返回指定状态下title阴影的颜色,(UIColor *)

imageForState:

//返回指定状态下的image ,(UIImage *)

backgroundImageForState:

//返回指定状态下的背景图片,(UIImage *)

attributedTitleForState:

//返回指定状态下的AttributedTitle,(NSAttributedString *)

backgroundRectForBounds

//(重绘)指定背景边界(请勿直接调用)

contentRectForBounds

//(重绘)指定内容边界(请勿直接调用)

titleRectForContentRect

//(重绘)指定文字标题边界(请勿直接调用)

imageRectForContentRect

//(重绘)指定按钮图像边界(请勿直接调用)