属性:
contentEdgeInsets:内容显示范围
titleEdgeInsets:标题显示范围
reversesTitleShadowWhenHighlighted:按钮高亮的时候是否改变阴影
imageEdgeInsets:图片显示范围
adjustsImageWhenHighlighted:按钮在高亮状态下图片变暗
adjustsImageWhenDisabled:按钮在高亮状态下变亮
showsTouchWhenHighlighted:按钮点击的时候高亮
tintColor:默认字体颜色
buttonType:按钮风格
currentTitle:当前标题等,同于button.title.text (只读)
currentTitleColor:当前标题颜色,标题颜色 (只读)
currentTitleShadowColor:当前标题阴影颜色
currentImage:当前图片
currentBackgroundImage:当前背景图片
currentAttributedTitle:当前富文本标题
titleLabel:标题标签
imageView:按钮图片视图
方法:
+ (instancetype)buttonWithType:(UIButtonType)buttonType; 创建button和定风格
- (void)setTitle:(nullable NSString *)title forState:(UIControlState)state;设置按钮的标题和状态
- (void)setTitleColor:(nullable UIColor *)color forState:(UIControlState)state;设置标题的颜色和状态
- (void)setTitleShadowColor:(nullable UIColor *)color forState:(UIControlState)state;设置阴影的颜色和状态
- (void)setImage:(nullable UIImage *)image forState:(UIControlState)state;设置按钮的图片和状态
- (void)setBackgroundImage:(nullable UIImage *)image forState:(UIControlState)state;设置背景颜色和状态
- (void)setAttributedTitle:(nullable NSAttributedString *)title forState:(UIControlState)state;设置富文本标题和状态
- (nullable NSString *)titleForState:(UIControlState)state;返回某个状态下的按钮标题
- (nullable UIColor *)titleColorForState:(UIControlState)state;返回某个状态下的按钮阴影标题
- (nullable UIColor *)titleShadowColorForState:(UIControlState)state;返回某个状态下的按钮阴影颜色
- (nullable UIImage *)imageForState:(UIControlState)state;返回某个状态下的按钮图片
- (nullable UIImage *)backgroundImageForState:(UIControlState)state;返回某个状态下的按钮背景图片
- (nullable NSAttributedString *)attributedTitleForState:(UIControlState)state;返回某个状态下的按钮的富文本标题
- (CGRect)backgroundRectForBounds:(CGRect)bounds; 按钮背景的范围
- (CGRect)contentRectForBounds:(CGRect)bounds; 按钮内容的范围
- (CGRect)titleRectForContentRect:(CGRect)contentRect; 按钮标题的范围
- (CGRect)imageRectForContentRect:(CGRect)contentRect;按钮图片的范围