UIButton 基础篇

        属性:

        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;按钮图片的范围

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值