How to give space between two cells in tableview?

前端 未结 26 1474
谎友^
谎友^ 2020-11-29 00:11

I want a space between two cell in table view,

I want cell like this,

\"enter<

26条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-29 00:51

    Objective - C

     UIView* separatorLineView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 3)];/// change size as you need.       
     separatorLineView.backgroundColor = [UIColor whiteColor];// you can also put image here
     [cell.contentView addSubview:separatorLineView];
    

    Swift 3 (This same will work for Swift 4 also)

    var separatorLineView = UIView(frame: CGRect(x: 0, y: 0, width: 320, height: 3))
    /// change size as you need.       
    separatorLineView.backgroundColor = UIColor.white
    // you can also put image here
    cell.contentView.addSubview(separatorLineView)
    

    It worked for me.

提交回复
热议问题