自定义button imageview 和 titleLabel 位置 大小等

it2022-05-05  102

@implementation QTShareIPhoneButton

 

-(instancetype)initWithFrame:(CGRect)frame {

    self = [super initWithFrame:frame];

    if (self) {

        self.contentMode = UIViewContentModeScaleAspectFit;

    }

    return self;

}

 

-(void)layoutSubviews {

    [super layoutSubviews];

    CGRect imageRect = self.imageView.frame;

    imageRect.size = CGSizeMake(24, 24);

    imageRect.origin.x = [Utility margin];

    imageRect.origin.y = 12;

    CGRect titleRect = self.titleLabel.frame;

    

    

    titleRect.origin.x = 61;

    titleRect.origin.y = 12;

    titleRect.size = CGSizeMake(200, 24);

    self.imageView.frame = imageRect;

    self.titleLabel.frame = titleRect;

}


最新回复(0)