How do I add an extra separator to the top of a UITableView?

后端 未结 8 2113
面向向阳花
面向向阳花 2021-02-06 22:20

I have a view for the iPhone that is basically split in two, with an informational display in the top half, and a UITableView for selecting actions in the bottom half. The prob

8条回答
  •  臣服心动
    2021-02-06 22:35

    I had the same problem and could not find an answer. So I added a line to the bottom of my table header.

    CGRect  tableFrame = [[self view] bounds] ; 
    CGFloat headerHeight = 100;        
    UIView * headerView = [[UIView alloc] initWithFrame:CGRectMake(0,0,tableFrame.size.width, headerHeight)];
    // Add stuff to my table header...
    
    // Create separator
    UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, headerHeight-1, tableFrame.size.width, 1)] ;
    lineView.backgroundColor = [UIColor colorWithRed:224/255.0 green:224/255.0 blue:224/255.0 alpha:1.0];
    [headerView addSubview:lineView];
    
    self.tableView.tableHeaderView = headerView;
    

提交回复
热议问题