【发布时间】:2013-11-29 14:14:34
【问题描述】:
我只想在 UITableView 中设置右边框?
到目前为止,我已经尝试过以下代码。但它在整个表格中设置边框,就像在 mac 中一样,但我想实现它应该只设置右边框:-
self.tableView.layer.borderWidth = 1.0;
【问题讨论】:
我只想在 UITableView 中设置右边框?
到目前为止,我已经尝试过以下代码。但它在整个表格中设置边框,就像在 mac 中一样,但我想实现它应该只设置右边框:-
self.tableView.layer.borderWidth = 1.0;
【问题讨论】:
您可以将视图添加到您想要大小的单元格的 contentView 中,而不是使用层,这会添加 1px 的边框:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
...
UIView *right = [[UIView alloc] initWithFrame:CGRectMake(319, 0, 1, cell.frame.size.height)];
right.backgroundColor = [UIColor redColor];
[cell.contentView addSubview:right];
【讨论】:
据我所知,您不能只为 UITableView 的一侧添加边框。在这里检查这个答案,它可以帮助你
【讨论】: