How to give space between two cells in tableview?

前端 未结 26 1476
谎友^
谎友^ 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 01:08

    1) first create 2 sections in table view. 2) create an empty cell. 3) create the cell with data you want to display. 4) use the method

    • (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.section==0) {

      if (indexPath.row % 2 != 1) { return 15.0; } else { return 100; } } else

      if (indexPath.row % 2 != 1) {
          return 100.0;
      } else {
          return 15.0;
      }
      

    }

    It will add space between the cells. It worked for me.

提交回复
热议问题