自定义LFBuybutton ,继承自UIbutton,在自定义的按钮中重写方法-(void)layoutSubviews
根据文字和按钮的X点的交换,实现文字和图片位置的交换
根据文字和按钮的X点的交换,实现文字和图片位置的交换
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#import "LFBuybutton.h"
@implementation
LFBuybutton
-(
void
)layoutSubviews
{
[
super
layoutSubviews
];
CGRect
titleF =
self
.titleLabel
.frame
;
CGRect
imageF =
self
.imageView
.frame
;
titleF
.origin
.x
= imageF
.origin
.x
;
self
.titleLabel
.frame
= titleF;
imageF
.origin
.x
= CGRectGetMaxX(titleF);
self
.imageView
.frame
= imageF;
}
@end
|
本文介绍了一种自定义的LFBuybutton按钮组件,该组件继承自UIbutton,并通过重写layoutSubviews方法实现了文字与图片的位置互换,使得按钮上的文字和图标布局更加灵活。
2334

被折叠的 条评论
为什么被折叠?



