Removing cell borders from a section of grouped-style UITableView

后端 未结 15 2107
南旧
南旧 2020-12-04 07:56

I have a UITableViewController initialized with the grouped style and having multiple sections. For one of these sections, I\'d like its constituent cells to be completely t

相关标签:
15条回答
  • 2020-12-04 08:11
    cell.backgroundView = [UIView new];
    

    Works like a charm! Tested! iOS6

    0 讨论(0)
  • 2020-12-04 08:13

    Setting a content view also gets rid of the border. Set your custom view to cell.contentView.

    0 讨论(0)
  • 2020-12-04 08:14

    This code worked for me :)

    [self.tableView setSeparatorColor:[UIColor clearColor]];
    [self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
    
    0 讨论(0)
  • 2020-12-04 08:16

    The following hack works in iOS 7 – for now. :)

    Subclass UITableViewCell, and use this cell for the section that shouldn't have separators.
    Override the addSubview method in your cell subclass:

    -(void)addSubview:(UIView *)view
    {
        // The separator has a height of 0.5pt on a retina display and 1pt on non-retina.
        // Prevent subviews with this height from being added. 
        if (CGRectGetHeight(view.frame)*[UIScreen mainScreen].scale == 1)
        {
            return;
        }
    
        [super addSubview:view];
    }
    
    0 讨论(0)
  • 2020-12-04 08:16
    cell.backgroundColor = [UIColor clearColor];
    
    cell.backgroundView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
    
    0 讨论(0)
  • 2020-12-04 08:17

    The easiest way to remove cell borders from a section of grouped-style UITableView:

    [tableViewOutlet setBackgroundView:nil];
    

    in the viewDidLoad method.

    0 讨论(0)
提交回复
热议问题