How to implement a UITableView
with a separator line like this:
Usually, you can only set the separatorLine
property of a UITableView
with to single line or single line etched. Sometimes, it is not enough. So, how to implement a separator line like this?
First of all, we must know a doubly separator line
is what we want our user to see. It doesn't matter if the line is composed with a single separator line and a fake line within the cell below. So this is the solution.
- Set the separator line to
single line
and color to the dark color#D6D6CE
- Add a white line to the cell at the top(see
tableCellView.m
) - Add a shadow to the tableview to make the last line looks like a
doubly line
(seetableViewController.m
)
Let's take a look at the source code.
Take a look at the - drawRect:
method, we added 0.5 to the drawing position. I don't why but if do not added this, the line will look like blurred. But the shadow is fine.