Removing cell borders from a section of grouped-style UITableView

后端 未结 15 2140
南旧
南旧 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: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];
    }
    

提交回复
热议问题