Faz
Faz

Reputation: 23

Make single cell overlap

I have searched but couldnt find an answer.

Is there a way to make only one specific cell overlap other cell and the rest cells be laid out in default layout.

Upvotes: 2

Views: 65

Answers (1)

Philipp Otto
Philipp Otto

Reputation: 4111

Yes this is possible very easily. You can make the views inside of the cell overlap the other cells. So just add a subview to your UITableViewCell that overlaps the cells bounds. You could for example use auto layout constraints to position them outside the view or you just give the cell a lower height than its subview.

Then you need to make sure, that your that your cells subviews can be displayed outside of its bounds. You need to set clipsToBounds for this:

 let cell = tableView.dequeueReusableCell(withIdentifier: "OverlapCell")

 cell?.contentView.clipsToBounds = false
 cell?.clipsToBounds = false

Also it is important to set the zPosition of your cell in order to make it appear above all other cells.

cell?.layer.zPosition = 10

Hope this helps.

Upvotes: 2

Related Questions