I wanted to set only right border in UITableView?
我想在UITableView中只设置右边框?
So far i have tried this below code. But it is setting the border in whole table as it is there in mac, But i wanted to achieve that it should set only right border :-
到目前为止,我已尝试过以下代码。但它在整个表格中设置边框,因为它在mac中,但我想实现它应该只设置正确的边框: -
self.tableView.layer.borderWidth = 1.0;
5
instead of using layer you can add a view to the contentView of the cell the size you want, this add border of 1px:
而不是使用图层,你可以添加一个视图到您想要的单元格的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];
2
As I know, you can't add border for one side of UITableView only. Check this answer here, it could help you
据我所知,您不能仅为UITableView的一侧添加边框。在这里查看这个答案,它可以帮助你
UITableView one sided Border color?
UITableView单面边框颜色?