开发者社区> 问答> 正文

UITableview的一个section下的各行Row之间可以设置间隔一段距离吗?

UITableview delegate中貌似只可以设置row的高度,有没有方法让我设置ow与row之间的距离?

展开
收起
a123456678 2016-07-20 14:37:35 2691 0
1 条回答
写回答
取消 提交回答
  •  (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
        static NSString *CELL_ID2 = @"SOME_STUPID_ID2";
        // even rows will be invisible
        if (indexPath.row % 2 == 1)
        {
            UITableViewCell * cell2 = [tableView dequeueReusableCellWithIdentifier:CELL_ID2];
    
            if (cell2 == nil)
            {
                cell2 = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
                                              reuseIdentifier:CELL_ID2];
                [cell2.contentView setAlpha:0];
                [cell2 setUserInteractionEnabled:NO]; // prevent selection and other stuff
            }
            return cell2;
        }
    
        [ccTableView setBackgroundColor:[UIColor clearColor]];
        cardsCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cardsCell"];
    
        if(cell == nil){
          NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"cardsCell" owner:self options:nil];
          cell = [topLevelObjects objectAtIndex:0];
        }
    
    2019-07-17 19:58:50
    赞同 展开评论 打赏
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载