【发布时间】:2012-01-12 03:06:24
【问题描述】:
我正在实现具有自定义背景并在点击时展开的 UITableViewCells。
我将自定义视图设置为我的 UITableViewCells 背景视图:(在 RowForIndexPath 中)
if (cell == nil) {
CGRect f = CGRectMake(0.0f, 0.0f, 300.0f, 50.0f);
cell = [[UITableViewCell alloc] initWithFrame:f reuseIdentifier:cellIdentifier];
UIView *back = [[UIView alloc] initWithFrame:CGRectMake(10.0f, 10.0f, 300.0f, 50.0f)];
back.layer.cornerRadius = 8.0f;
[back setBackgroundColor:[UIColor blackColor]];
这很好用,通过设置 backgroundView 而不是 contentView,我的 backgroundView 在展开后会缩放以适应单元格的新大小(点击后更改 heightForRowAtIndexPath 中的高度)。
我现在的问题是我想在单元格之间留出几个像素的垂直空间。使用上述方法将使圆形黑色单元格“背靠背”显示。
有没有办法在单元格之间添加垂直空间,或者我可以采取完全不同的方法来获得所需的单元格外观?
提前致谢。
【问题讨论】:
-
我不确定您在寻找什么,但作为参考,请查看:stackoverflow.com/questions/3952705/gap-between-uitableviewcell/…
标签: ios uitableview