Remove separator in grouped UITableView

て烟熏妆下的殇ゞ 提交于 2019-12-10 17:45:22

问题


I need to make a grouped table view with custom cells. Each cell must have a background image, so that image of one cell will touch the image of the second cell and so on. I've tried to set the separatorStyle to None, but I still get the transparent separator between cells. Help me, please, remove this space between cells.

Have a good day, Thanks!


回答1:


I found that when I set the background image, the separator went away automatically. The problem is that I want it to show up.

Here's what I did:

Create a custom UITableViewCell class. In the respective init method do:

    // Create a background image view.  
    self.backgroundView = [[UIImageView alloc] init];

Then in your controller that manages the UITableView:

- (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    // After all of the cell dequeue/allocation...

    UIImageView *backgroundView = (UIImageView *)cell.backgroundView;
    backgroundView.image = [UIImage imageNamed:@"your_image"];
}


来源:https://stackoverflow.com/questions/8358287/remove-separator-in-grouped-uitableview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!