1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//
// ZanButton.m
// redstar
//
// Created by admin on 15/11/2.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "ZanButton.h"
@implementation ZanButton
// 修改按钮内部子控件的frame
- (void)layoutSubviews
{
[super layoutSubviews];
// 1.imageView
CGFloat imageX = 5;
CGFloat imageY = 0;
CGFloat imageW = 17;
CGFloat imageH = 18;
self.imageView.frame = CGRectMake(imageX, imageY, imageW, imageH);
// 2.title
CGFloat titleX = imageW + imageX + 4;
CGFloat titleY = 1;
CGFloat titleW = self.bounds.size.width - (imageW + imageX + 4);
CGFloat titleH = self.bounds.size.height - titleY;
self.titleLabel.frame = CGRectMake(titleX , titleY, titleW, titleH);
}
@end