iOS different constraints for different devices

xskit picture xskit · Feb 6, 2018 · Viewed 8.8k times · Source

I have a ViewController designed for iPhone SE

enter image description here

As you can see I also have a constraint Align Top to: Safe Area Equals 75

The question is, is it possible to change this value for iPhone 8 and iPhone 8 Plus? For example:

  • SE = 75
  • 8 = 85
  • 8 Plus = 105

Answer

tryKuldeepTanwar picture tryKuldeepTanwar · Apr 15, 2019

Easy way!

To overcome this issue I created a small library so you don't have to write a single line of code just assign the class (NSLayoutHelper) to your constraint and you'll be able to update your constraint for all the devices differently.

enter image description here

For updating constraints

enter image description here

Output

enter image description here