【问题标题】:How to set the space between table view cell and removing white color for background contentView如何设置表格视图单元格之间的空间并删除背景内容视图的白色
【发布时间】:2014-06-05 14:24:28
【问题描述】:

如何去除单元格和角落之间的白色我在容器视图中使用了清晰的颜色,但没有去除白色。

我采用表格视图上的自定义单元格。 cell.contentView.backgroundColor= [UIColor clearColor]; cell.contentView.layer.cornerRadius=10;

【问题讨论】:

    标签: ios objective-c uitableview


    【解决方案1】:

    设置 UITableView 样式分组。并将每个单元格设置在不同的部分。然后在下面添加代码:

    - (float)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
        //this is the space
        return 50;
    }
    

    要更改单元格之间的颜色,您应该这样做:

    - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
        UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, 5)];
        v.backgroundColor = [UIColor whiteColor];
        return v;
    }
    

    如果你想改变背景颜色,你应该在 cell.contenrView.backgroundColor 中设置你需要的颜色。

    【讨论】:

    • 谢谢你...但我只要求单元格背景
    猜你喜欢
    • 2019-02-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-28
    • 1970-01-01
    相关资源
    最近更新 更多