title: How should I programmatically update constraints for a dynamic view?
body: <p>I want to know the best practice for updating views/constraints to have a dynamic view with multiple possible (visible) subviews. In this simple example, let's say I want a <strong>custom</strong> <code>UITableViewCell</code> with the possibility of two 'states', one with a header and a body label, and one with only the body label, like the images below. <strong>Important</strong>: I am not looking for a way to create these exact two states, this is just an example. I know that a regular cell has <code>subtitle</code> which would achieve this, but my real problem is way more complex.</p>
  
  <p>First state:</p>
  
  <p><a href="https://i.stack.imgur.com/Yjzgj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Yjzgj.png" alt="First state"></a></p>
  
  <p>Second state:</p>
  
  <p><a href="https://i.stack.imgur.com/PXwR9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PXwR9.png" alt="Second state"></a></p>
  
  <p>One option would be to create these two cells as separate cells, but I want to find out if there's any 'accepted' way to make a single cell (the first one) and have it display in various states - preferably without having to handle <strong>a ton</strong> of programmatic states.</p>
  
  <p>First of all, I assume that both labels has to be constrained to the top-margin of the cell itself. If I don't do this, both states won't be possible, right? Or is there another way to get the second state from the first view?</p>
  
  <p>How should the constraints be set up, and how should I handle them in code - to achieve a single view with different layouts?</p>