调整cell的间距

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self = [[NSBundle mainBundle] loadNibNamed:@"MessageNotificationTableViewCell" owner:nil options:nil][0];
        // self.contentView.backgroundColor=[UIColor clearColor];
        //self.backgroundColor=[UIColor clearColor];
        self.selectionStyle=UITableViewCellSelectionStyleNone;
        UIView *view = [[UIView alloc ]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 10)];
        
        view.backgroundColor =MAIN_COLOR_GRAY;
        
        [self.contentView addSubview:view];
        
       
    }
    return self;
}

另一种方法

自定义cell,然后重写cell的setFrame方法
-(void)setFrame:(CGRect)frame {
    frame.y += 10;
    [super setFrame:frame];
}

每个cell设置frame时,都给它的y值增加10的位置 

原文地址:https://www.cnblogs.com/athook/p/4792202.html