tableView 的headerView根据里面的label可

2019-08-12  本文已影响0人  ljzza

UIView *headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, DEVICE_SCREEN_WIDTH, 100)];
headerView.backgroundColor = COLOR_WHITE;

UILabel *titleLabel = [[UILabel alloc]init];
//CGRectMake(18, 0, headerView.width - 36, headerView.height
titleLabel.textColor = COLOR_HEX(0x20508E, 1.0);
titleLabel.font = [UIFont systemFontOfSize:15.0];
titleLabel.text = self.titleString;
titleLabel.numberOfLines = 0;

[titleLabel sizeToFitVerticalWithMaxWidth:DEVICE_SCREEN_WIDTH - 36];
titleLabel.x = 18;
titleLabel.y = 10;
[headerView addSubview:titleLabel];
headerView.height = CGRectGetMaxY(titleLabel.frame) + 10;
_tableView.tableHeaderView = headerView;
上一篇下一篇

猜你喜欢

热点阅读