标签:
建一个类LTview
重写初始化过程
- (instancetype)initWithFrame:(CGRect )frame{
self = [super initWithFrame:frame];
if(self){
[self creatLabel:frame];
[self creatTextField:frame];
}
reture self;
}
- creatLabel:(CGRect)frame{
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake:(0, 0, frame.size.width / 3, frame.size.height);
[self addSubview:label]; //将label添加到LTview的对象上
[label release];
}
- creatTextField:(CGRect)frame{
UITextField *field = [[UITextField alloc] initWithFrame:CGRectMake:(frame.size.width / 3, 0, frame.size.width * 2 / 3, frame.size.height)];
[self addSubview:field];
[field release];
}
标签:
原文地址:http://www.cnblogs.com/lion-witcher/p/5078399.html