默认情况下,uitableview中有一个单行分隔符。
但我想把我的定制产品线作为分隔符。
有可能吗?多么?
发布于 2009-09-03 10:20:48
如果您不想使用UITableView的separatorColor属性更改分隔符的颜色,则可以将separatorStyle属性设置为UITableViewCellSeparatorStyleNone,然后执行以下任一操作:
例如,如果您的表当前显示5行,您可以将其更新为显示9行,而索引1、3、5、7处的行将是分隔单元。
发布于 2013-02-22 03:11:47
更好的解决方案是使用单元格的当前宽度和高度。如下所示:
UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, cell.contentView.frame.size.height - 1.0, cell.contentView.frame.size.width, 1)];
lineView.backgroundColor = [UIColor darkGrayColor];
[cell.contentView addSubview:lineView];
发布于 2013-03-11 14:09:18
如果您需要为不同的行使用不同的分隔符颜色,或者您希望分隔符在点击时突出显示该行时保持可见,请尝试以下操作:
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
// We have to use the borderColor/Width as opposed to just setting the
// backgroundColor else the view becomes transparent and disappears during
// the cell's selected/highlighted animation
UIView *separatorView = [[UIView alloc] initWithFrame:CGRectMake(0, 43, 1024, 1)];
separatorView.layer.borderColor = [UIColor redColor].CGColor;
separatorView.layer.borderWidth = 1.0;
[cell.contentView addSubview:separatorView];
这假设您的单元格的背景色是透明的。
上面的解决方案来自一些广泛的实验。以下是我的发现中的一些笔记,我相信它们会对人们有所帮助:
处于正常“未选中”状态的
选定单元格后,将立即显示以下内容,而不显示任何动画:
取消选中单元格时,将开始播放取消突出显示的动画:
中使用backgroundView
https://stackoverflow.com/questions/1374990
复制相似问题