How to remove a gray line on top of a UITableView

Initialize the UIViewController code:

    self.view.backgroundColor= [UIColor whiteColor];
    CGSize boundsSize = self.view.bounds.size;
    CGRect rectTableViewFrame = CGRectMake(0, 0, boundsSize.width, boundsSize.height - 64);
    UITableView* contentTableView = [[UITableView alloc] initWithFrame:rectTableViewFrame];

    contentTableView.backgroundColor = [UIColor clearColor];
    contentTableView.separatorColor = [UIColor clearColor];
    contentTableView.separatorStyle = UITableViewCellSeparatorStyleNone;

Next, add a custom UITableView view (title):

    CustomView* customView = [[CustomView alloc] init];
    CGRect customViewFrame = customView.frame;
    customViewFrame.origin.y = - customView.size.height;
    customView.frame = customViewFrame;

    contentTableView.contentOffset = CGPointMake(0, customViewFrame.origin.y);
    contentTableView.contentInset = UIEdgeInsetsMake(customViewFrame.frame.size.height, 0, 0, 0);
    [contentTableView addSubview: customView];

Problem: there is a gray line when scrolling through the contents of the TableView of the top user view ... How do I delete this? I do not use methods:

    -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
    -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section

But if you use a simple view with a white background color, there is no line.

+4
source share
1 answer

you can try to set the style without a line, for example:

contentTableView.separatorStyle = UITableViewCellSeparatorStyleNone;

and add a gray line at the bottom UITableViewCell.

0
source

All Articles