从分组样式的 UITableView 的一部分中删除单元格边框 [英] Removing cell borders from a section of grouped-style UITableView

查看:23
本文介绍了从分组样式的 UITableView 的一部分中删除单元格边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 UITableViewController 用分组样式初始化并有多个部分.对于这些部分之一,我希望其组成单元完全透明且没有边框.我计划为本节中的每一行分配一个自定义视图,但是让该自定义视图被分组表格单元格包围看起来很糟糕:(

I have a UITableViewController initialized with the grouped style and having multiple sections. For one of these sections, I'd like its constituent cells to be completely transparent and have no border. I plan to assign a custom view for every row in this section, but having that custom view surrounded by the grouped table cell looks bad :(

以下使单元格的背景颜色变为黑色而不是透明...我仍然不知道如何摆脱边框.

The following makes the background color of a cell black instead of transparent... And I still don't know how to get rid of the border.

cell.backgroundColor = [UIColor clearColor];

有什么指点吗?谢谢!

推荐答案

注意: 这似乎不适用于 iOS7 及更高版本.对于 iOS7,请尝试这个答案.

NOTE: This doesn't appear to be working in iOS7 and above. For iOS7 try this answer.

对于 iOS6 及以下版本,要从分组表视图单元格中的单元格中移除分组背景:

For iOS6 and below, to remove the grouped background from a cell in a grouped table view cell:

这不起作用

cell.backgroundView = nil; // Did Not Work

这样做

cell.backgroundView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];

如果您已迁移到 ARC(我听说此方法有效,但尚未对其进行测试)

If you have moved to ARC (I've heard this works, but haven't tested it)

cell.backgroundView = [UIView new];

这篇关于从分组样式的 UITableView 的一部分中删除单元格边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆