UIButton

基本属性

  1. contentEdgeInsets, titleEdgeInsets, imageEdgeInsets: 调整边距的三个属性.详细介绍
  2. reversesTitleShadowWhenHighlighted: 设置高亮时是否改变阴影.
  3. adjustsImageWhenHighlighted: 高亮状态下,image深一点.
  4. adjustsImageWhenDisabled: 被禁用状态,image浅一点.
  5. showsTouchWhenHighlighted: 触摸时候,会发光.
  6. tintColor: 所有的常用控件,都有tintColor属性。其中,UIView也有这个属性,可想而知继承UIView的控件也都有tintColor了。使用场景:当父视图更改了tintColor为red,那么它所有的一级子视图tintColor全部为red,除非你主动设置过子视图的tintColor。它再往下的子视图的tintColor则遵循直接父视图的tintColor 。
  7. buttonType: 按钮类型.
  8. currentTitle: 按钮当前的标题.(只读)
  9. currentTitleColor: 当前title颜色.(只读)
  10. currentTitleShadowColor:当前title阴影颜色.(只读)
  11. currentImage: 当前image.(只读)
  12. currentBackgroundImage:当前背景图片.(只读)
  13. currentAttributedTitle:当前富文本.(只读)
  14. titleLabel:存放标题的label.(只读)
  15. imageView:存放图片的imageView.(只读)

方法

//设置某种状态下的标题
- (void)setTitle:(nullable NSString *)title forState:(UIControlState)state; 
//设置某种状态下标题的颜色
- (void)setTitleColor:(nullable UIColor *)color forState:(UIControlState)state ;
//设置title在不同状态下的阴影颜色
- (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;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值