我不知道我做錯了什麼:添加節頭以表
-(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