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

后端 未结 8 2288
面向向阳花
面向向阳花 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:37

    Add a separator between header view and first row :- In view for Header in section delegate method add a subview self.separator //@property (nonatomic, strong) UIImageView *separator;

    - (CGFloat)tableView:(UITableView *)tableView
    heightForHeaderInSection:(NSInteger)section {
    
    return 41; 
    }
    
    
    - (UIView *)tableView:(UITableView *)tableView
    viewForHeaderInSection:(NSInteger)section {
    
    self.headerView = [[UIView alloc] init];
    self.headerView.backgroundColor = [UIUtils colorForRGBColor:TIMESHEET_HEADERVIEW_COLOR];
    
    self.separator = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"seperator.png"]];
    self.separator.frame = CGRectMake(0,40,self.view.frame.size.width,1);
    [self.headerView addSubview:self.separator];
    return self.headerView;
    
    }
    

提交回复
热议问题