title: Swift : set constraints to UICollectionViewCell programmatically
body: <p>I've a scenario where 9 UICollectionViewCell are generated programmatically. It should be arranged in <strong>3*3 format in all iPhone variant.</strong> </p>
  
  <p>Also the <strong>button size to get increased or decreased based on iPhone device.</strong> <em>For eg.,</em> In iPhone 4s it should be small so that 3*3 format is arranged properly and in iPhone 6 Plus it should be big enough so that 3*3 format is achieved.</p>
  
  <p><a href="https://i.stack.imgur.com/YxKAZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YxKAZ.png" alt="Screenshot 1"></a></p>
  
  <p>I had tried setting constraints programmatically but didn't get desired result.</p>
  
  <p><a href="https://i.stack.imgur.com/ETNzm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ETNzm.png" alt="Screenshot 2"></a></p>
  
  <p><strong>How to set constraints programmatically to UICollectionViewCell such that purpose is achieved?</strong></p>