title: How to set left and right margin for UITableView in Swift
body: <p>I am using <em>UITableView</em> inside my controller that displays cells with some informations (title, subtitle and image). I would like to add some padding to the <em>tableView</em>, but I can't find the right solution. This is my code for table view:</p>
  <pre><code>private let tableView: UITableView = {
      let tableView = UITableView(frame: .zero, style: .grouped)
      tableView.translatesAutoresizingMaskIntoConstraints = false
      tableView.backgroundColor = .clear
      tableView.separatorStyle = .none
      tableView.allowsSelection = false
      tableView.showsVerticalScrollIndicator = false
      tableView.estimatedRowHeight = 44.0
      tableView.rowHeight = UITableView.automaticDimension
      return tableView
  }()
  </code></pre>
  <p>Inside <em>viewDidLoad()</em> I setup constraints for that <em>tableView</em></p>
  <pre><code>NSLayoutConstraint.activate([
      tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
      tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
      tableView.topAnchor.constraint(equalTo: view.topAnchor),
      tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor)
  ])
  </code></pre>
  <p>Right now my view looks like this:</p>
  <p><a href="https://i.stack.imgur.com/Fyuqt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Fyuqt.png" alt="enter image description here" /></a></p>
  <p>Now when I try to configure <em>contentInset</em> property inside my <em>tableView</em> closure by adding this:</p>
  <pre><code>tableView.contentInset = .init(top: 0, left: 23.5, bottom: 0, right: -23.5)
  </code></pre>
  <p>As you can see it only added space on the left side, but looking at the <em>debug view hierarchy</em>
  I can say that it moved that <em>contentView</em> to the right side (It's still have the same width as its superview)
  <a href="https://i.stack.imgur.com/yp2rU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yp2rU.png" alt="enter image description here" /></a></p>
  <p><a href="https://i.stack.imgur.com/rFYQk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rFYQk.png" alt="enter image description here" /></a></p>
  <p>Info from view debugger.
  <em>TableView</em>:</p>
  <pre><code>&lt;UITableView: 0x7fba82016000; frame = (0 0; 390 844); clipsToBounds = YES; gestureRecognizers = &lt;NSArray: 0x60000023de90&gt;; layer = &lt;CALayer: 0x600000c4b9e0&gt;; contentOffset: {-23.333333333333332, -47}; contentSize: {390, 635.66666666666663}; adjustedContentInset: {47, 23.5, 34, -23.5}; dataSource: &lt;Myapp.WelcomeViewController: 0x7fba81c08f60&gt;&gt;
  </code></pre>
  <p>and First cell:</p>
  <pre><code>&lt;UITableViewCellContentView: 0x7fba84021250; frame = (0 0; 390 87); gestureRecognizers = &lt;NSArray: 0x6000002cf900&gt;; layer = &lt;CALayer: 0x600000c2b900&gt;&gt;
  </code></pre>
  <p><em>TableView</em> has the same width as cell (390 vs 390). How can I add my paddings to the left and right to the <em>tableView</em>, without making constraints on that <em>tableView</em> (I want that area to also be scrollable)</p>