自定义LFBuybutton ,继承自UIbutton,在自定义的按钮中重写方法-(void)layoutSubviews
根据文字和按钮的X点的交换,实现文字和图片位置的交换
#import "LFBuybutton.h"
@implementation LFBuybutton
-(void)layoutSubviews
{
[super layoutSubviews];
CGRect titleF = self.titleLabel.frame;
CGRect imageF = self.imageView.frame;
titleF.origin.x = 0;
self.titleLabel.frame = titleF;
imageF.origin.x = CGRectGetMaxX(titleF);
self.imageView.frame = imageF;
}
@end