自定义Button的图片文字位置
2016-07-24 本文已影响87人
伊蕊飘零
//在这个layoutSubviews中自定义你想要的位置
//这里是创建一个类,继承自UIButton
#import "WWMarginButton.h"
@implementation WWMarginButton
- (void)layoutSubviews{
[super layoutSubviews];
[self.imageView makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(self);
make.leading.equalTo(5);
}];
[self.titleLabel makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.imageView.top);
}];
//这里的x 我自定义了x ww_x是frame.size.x
self.titleLabel.ww_X = CGRectGetMaxX(self.imageView.frame) + 10;
}
@end