It's hard to say without more info, but I think the best solution would be to subclass UIView, something like this:
SWIFT 4.0
class MySymmetricView {
@IBInspectable var inset: Float = 10.0 // Put your constraints here, @IBInspectable will expose them to IB, you can also set your constants here
required init?(coder: NSCoder) {
super.init(coder: coder)
setupConstraints()
}
override init(frame: CGRect) {
super.init(frame: frame)
setupConstraints()
}
func setupConstraints() {
NSLayoutConstraint(item: self, attribute: .leading, relatedBy: .equal, toItem: superview, attribute: .leadingMargin, multiplier: 1.0, constant: inset).isActive = true
NSLayoutConstraint(item: self, attribute: .top, relatedBy: .equal, toItem: superview, attribute: .leadingMargin, multiplier: 1.0, constant: inset).isActive = true
}
}
Or subclass the constraints themselves in a similar way.