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) ;

    }

  • 相关阅读:
    BZOJ-1016 最小生成树计数
    BZOJ-1003 物流运输
    BZOJ-1009 GT考试
    【NOIP2014】伤感·伤感·伤感
    BZOJ-1033 杀蚂蚁
    NOIP一系列模拟赛小结
    2014·NOIP 新的历程,新的开始
    35. Search Insert Position
    29. Divide Two Integers
    28. Implement strStr()
  • 原文地址:https://www.cnblogs.com/starainDou/p/5183180.html
Copyright © 2011-2022 走看看