嗨,我试图在 tableview 标题上设置自定义视图,但自定义视图不适合标题。
自定义视图如下图所示,在此图像中,自定义视图为橙色,标题视图为灰色。但我希望自定义视图充满标题视图。
请帮忙。
我的代码:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *sectionView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, _TableList.frame.size.width, 80)];
header = [[HeaderView alloc] initWithFrame:CGRectMake(sectionView.frame.origin.x, sectionView.frame.origin.y, sectionView.frame.size.width, sectionView.frame.size.height)];
[sectionView addSubview:header];
sectionView.tag=section;
sectionView.backgroundColor = [UIColor grayColor];
UITapGestureRecognizer *headerTapped = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(sectionHeaderTapped:)];
[sectionView addGestureRecognizer:headerTapped];
return sectionView;
}