我不知道我做错了什么:添加节头以表
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
/* Table header */
HeaderView *tableHead = [[HeaderView alloc]initWithFrame:CGRectMake(0, 0, self.myTableView.frame.size.width, 40)];
[tableHead initialize];
return tableHead;
}
我的看法类很简单:
@interface HeaderView()
@property (nonatomic) UILabel *headerLbl;
@end
@implementation HeaderView
-(instancetype)init{
self = [super init];
return self;
}
-(void)initialize{
[self createUserInterface];
[self createConstraints];
}
-(void)createUserInterface{
self.backgroundColor = [UIColor defaultGray];
_headerLbl = [UILabel new];
_headerLbl.font = [UIFont systemFontOfSize:13];
_headerLbl.textColor = [UIColor fontGray];
_headerLbl.numberOfLines = 0;
[self addSubview:_headerLbl];
}
-(void)createConstraints{
[_headerLbl mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.mas_centerX);
make.centerY.equalTo(self.mas_centerY);
}];
}
想创建头鉴于我的表的方法,但它没有。
检查此链接:http://stackoverflow.com/questions/15611374/customize-uitableview-header-section – VJVJ