Strange UITableViewCell shadow behaviour

You don’t see the shadow because the cell above/below is higher in the view-hierarchy depending on whether it was dequeued before or after your custom cell. Check out the View-Hierarchy-Debugger in Xcode to spot the issue.

You have a couple of possible solutions but I will outline 2 of them here:

  1. You can use bringSubviewToFront in your tableView to make sure your custom cell is always on top.
override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
    if cell.isKind(of: MyCustomShadowCell.self) {
  1. Another solution would be to set the layer.zPosition of the cell to something high, so that it’s always on top. Imo that’s a bit hack-ish but if you wanna try: layer.zPosition = CGFloat.greatestFiniteMagnitude.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top