Пользовательский класс ограничений IBDesignable & IBInspectable
import UIKit
@IBDesignable
class MyConstraint: NSLayoutConstraint {
@IBInspectable
var iPhone8: CGFloat = 0 {
didSet {
if UIScreen.main.bounds.maxY == 667 &&
UIScreen.main.bounds.maxX == 375 {
constant = iPhone8
}
}
}
@IBInspectable
var iPhone8Plus: CGFloat = 0 {
didSet {
if UIScreen.main.bounds.maxX == 414 &&
UIScreen.main.bounds.maxY == 736 {
constant = iPhone8Plus
}
}
}
}
Установить пользовательский класс ограничений
![enter image description here](https://i.stack.imgur.com/FFhzy.png)
![enter image description here](https://i.stack.imgur.com/7AlnW.png)
![enter image description here](https://i.stack.imgur.com/e0JpN.png)