iCode
iCode

Reputation: 1466

Remove line above section

I always get a line above my custom section view. How can I remove it?

Upvotes: 3

Views: 845

Answers (3)

Adam
Adam

Reputation: 1913

Add the line headerView.clipsToBounds = true in your viewForHeader method

Upvotes: 0

amurcia
amurcia

Reputation: 791

Try this, this code works for me:

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {

        UILabel *sectionHeader = [[UILabel alloc] initWithFrame:CGRectNull];
        sectionHeader.hidden = YES;
        return sectionHeader;

}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {

        return 0;
}

Hope it helps!

Upvotes: 3

user2105505
user2105505

Reputation: 706

Check the style of your UITableView in the interface builder. If it is grouped, then it will have lines like what you are seeing. If it is plain, it shouldn't. I believe plain is the default setting, so my next guess is that the lines are in fact from the bottom of the UITableViewCell that is on top of the header. Try changing the separator to none or single line etched and see if that changes the line.

EDIT: I setup a default UITableView in the Interface Builder and got this:

Default TableView

As you can see, there is no line above the section. Otherwise it looks just like yours. My next question would be do you set any properties in your UITableViewController's code? Something like cellHeight or other might affect it, but I don't know for sure. Also try throwing a TableViewController into your storyboard and manually add static sections to it to see if these have the same result.

Upvotes: 1

Related Questions