title: How to update auto layout constraints in SubClass of UIView on orientation change
body: <p>I created a <code>UIView</code> subclass and added some imageViews and labels in it. I used Visual Format to create <code>constraints</code>. And the view layout is different for different size class. I used below code to identify the size class.</p>
  
  <pre><code>let rule = UITraitCollection(horizontalSizeClass: .regular)
  let isHorizontalRegular = self.traitCollection.containsTraits(in: rule)
  if isHorizontalRegular {
  // constraints for  Horizontal Regular size class
  } else {
  // constraints for  other size class
  }
  </code></pre>
  
  <p>Since I was not getting the size class information in <code>init</code> method so I created all the auto layout <code>constraints</code> are created in <code>updateConstraints()</code> method.</p>
  
  <p>Based on this implementation I'm have some questions.</p>
  
  <ol>
  <li>Is it correct approach to create all the <code>constraint</code> in overridden method <code>updateConstraints()</code>?</li>
  <li>If not, which is the west way to create auto layout <code>constraints</code> based on size class.</li>
  <li>How can I update the auto layout <code>constraints</code> on orientation change.(since i'm using visual format to create auto layout <code>constraints</code>)?</li>
  </ol>
  
  <p>I know I can solve my problem using <code>UIViewController</code> life cycle method. But I'm using <code>@IBDesignable</code> to render the View on storyboard. So is it possible to achieve these within <code>UIView</code> subclass.</p>
  
  <p>Please help me to solve these questions.</p>