正确显示UITableView上的边框 [英] Showing border on UITableView properly

查看:126
本文介绍了正确显示UITableView上的边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过在其上显示边框来完善表视图. 当前是这样的:

I am trying to polish up my tableview by showing a border on it. This is how it currently looks like:

一切都很好,请期待底部.我希望边框位于最后显示的单元格分隔符的底部.

Everything is fine expect the bottom part. I want the border to be on the bottom of the last showing cell's separator.

这是没有边框时的样子:

This is how it looks like when without the border:

我正在使用像这样的页脚并添加这样的边框:

I am using a footer like this and add the border like this:

self.tableView.tableFooterView = UIView()
self.tableView.backgroundColor = UIColor.clearColor()


tableView.layer.masksToBounds = true
tableView.layer.borderWidth = 2.0

注意

我忘了提及的另一件事.我想到了根据有多少个单元格来设置边框的高度.是的,我将始终具有相同数量的单元格,但是在不同的屏幕上,并非所有单元格都会显示.

Another thing i forgot to mention to think about. I thought of putting the height of the border according to how many cells there are. Yes i will always have the same amount of cells however on different screens, not all cells will be showing.

推荐答案

tableview.layer.borderWidth=2.0;
tableview.layer.borderColor=[[UIColor blackColor].CGColor];

您需要对表视图进行严格约束的IBoutlet

you need to take IBoutlet of hight Constraint of your Table View

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *TblHeightConstraint;

设置桌子高度

TblHeightConstraint.constant = yourCellHight * [NumberofCells];

它将在白天将您的桌子调高.因此您的边框将根据单元格的数量显示.

it will set your table hight daynamically.so Your border will show according to number of cell.

这篇关于正确显示UITableView上的边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆