AutoLayout does allow you to have different constraints based on screen, but it's only limited to orientation changes, and iPad vs iPhones. You'll have to do it programmatically.
This link will show you how to get the device, and then once you have that, you need to make an @IBOutlet to your constraint, and then you can change its .constant
property to either 40, 50, or 60
public extension UIDevice {
var modelName: String {
var systemInfo = utsname()
uname(&systemInfo)
let machineMirror = Mirror(reflecting: systemInfo.machine)
let identifier = machineMirror.children.reduce("") { identifier, element in
guard let value = element.value as? Int8, value != 0 else { return identifier }
return identifier + String(UnicodeScalar(UInt8(value)))
}
switch identifier {
case "iPhone4,1": return "iPhone 4s"
case "iPhone8,1": return "iPhone 6s"
case "iPhone8,4": return "iPhone SE"
default: return identifier
}
}
}
Now you can use it like so:
@IBOutlet weak var myConstraint: NSLayoutConstraint!
override func viewDidLoad() {
super.viewDidLoad()
if UIDevice.current.modelName == "iPhone 4s" {
myConstraint.constant = 30
}
else if UIDevice.current.modelName == "iPhone SE" {
myConstraint.constant = 50
}
else if UIDevice.current.modelName == "iPhone 6s" {
myConstraint.constant = 60
}
}