-1

I want my custom cell to occupy not the entire width of the screen, but only part of it and to be in the center of its row. For example:

example

You can see little spaces on the left and right sides of each cell. I was able to achieve this by creating a UIView hierarchy, but then another problem arises for me. So I decided to find out if it is possible to do this without adding additional views?

MaxB
  • 635
  • 1
  • 9
  • 22

1 Answers1

-1

A good approach is using Auto Layout. I would recommend using a custom xib that subclasses UITableViewCell. Once created, try implementing these constraints in the xib file:

  • Leading Space to Container = Margin
  • Trailing Space to Container = Margin
  • Top Space to Container = 20
  • Bottom Space to Container = 20

Hope this helps.

Miguel Tepale
  • 289
  • 5
  • 15