zoukankan      html  css  js  c++  java
  • 封装实现UIButton左文字右图片

    #import "TitleButton.h"

    @implementation TitleButton

    - (instancetype)initWithFrame:(CGRect)frame {

        if (self = [super initWithFrame:frame]) {

            [self setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];

            self.titleLabel.font = [UIFont boldSystemFontOfSize:16];

       [self setTitle:@"title" forState:UIControlStateNormal];

            [self setImage:[UIImage imageNamed:@"navigationbar_arrow_down"] forState:UIControlStateNormal];

            [self setImage:[UIImage imageNamed:@"navigationbar_arrow_up"] forState:UIControlStateSelected];

         }

        return self;

    }

     

    /** 设置内部imageViewframe */

    //- (CGRect)imageRectForContentRect:(CGRect)contentRect

    //{

    //    CGFloat x = ;

    //    CGFloat y = ;

    //    CGFloat width = ;

    //    CGFloat height = ;

    //    return CGRectMake(x, y, width, height)

    //}

    /** 设置内部titleLabelframe */

    //- (CGRect)titleRectForContentRect:(CGRect)contentRect

    //{

    //    CGFloat x = ;

    //    CGFloat y = ;

    //    CGFloat width = ;

    //    CGFloat height = ;

    //    return CGRectMake(x, y, width, height)

    //    

    //}

    - (void)layoutSubviews

    {

        [super layoutSubviews]; 

        //titleLablex

        self.titleLabel.x = 0;

        //imageViewx

        self.imageView.x = CGRectGetMaxX(self.titleLabel.frame) ;

    }

  • 相关阅读:
    JS: Promise
    JS: 数据结构与算法之栈
    JS: 数组乱序
    JS: 数组扁平化
    JS:函数柯里化
    JS: 防抖节流
    JS:事件委托
    理解Node.js(译文)
    Javascript闭包入门(译文)
    你真的懂ajax吗?
  • 原文地址:https://www.cnblogs.com/starainDou/p/5183180.html
Copyright © 2011-2022 走看看