Justus Jianxing Zhang
Justus Jianxing Zhang

Reputation: 410

ios tableView clearColor seperator

I have set my tableView's background color, and I want there is space(10px) around each cell show that color.

e.g.(ignore the red line)

enter image description here

What I am doing now is make the cell embed a smaller view, and set the cell's background to be clear. But it is annoying to create such embed view again and again.

So, I am seeking for a better solution, I believe it would be good if i can increase separator's height. But the old answers did not solve my problem.

(How to increase the UITableView separator height?)

EDIT:

However, if I add my own separator in cell. I may not able to set the cell having round corner

Upvotes: 1

Views: 751

Answers (2)

NRitH
NRitH

Reputation: 13893

  1. Set the tableView's separatorStyle to .None.
  2. Create a custom UITableViewCell subclass.
  3. In the storyboard (or xib if you created one for the custom cell), add a subview that's inset the amount that you want padded on all four sides.
  4. If you want rounded views, do that on the custom cell's subview (e.g. subview.layer.cornerRadius = 10.0, subview.layer.masksToBounds = true).
  5. Set the custom cell's ContentView to have a clear background.
  6. Set the table view's background to that lovely shade of blue.
  7. Set the cell subview's background color to white.

You don't have to use the cell repeatedly in InterfaceBuilder. Just give the cell an ID, and in your implementation of the table view's data source, dequeue a cell instance using that ID and set the values of the labels inside it.

Upvotes: 2

MSU_Bulldog
MSU_Bulldog

Reputation: 3519

Have you thought of just making the cell height taller and putting your own separator on the bottom of your custom cells? Nice table layout by the way.

Upvotes: 1

Related Questions