热门标签 | HotTags
当前位置:  开发笔记 > 前端 > 正文

如何在UITableView中只设置右边框?-HowtosetonlyrightborderinUITableView?

IwantedtosetonlyrightborderinUITableView?我想在UITableView中只设置右边框?Sofarihavetriedthisb

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;

2 个解决方案

#1


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


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单面边框颜色?


推荐阅读
author-avatar
小嫣师妹
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有