Constraining mapping to a variable

I don't know how to set constrant.height to a constant value:

override func updateConstraints() {
    layout(view) { view in
        let viewHeight = 67

        view.top == view.superview!.top
        view.left == view.superview!.left
        view.height == viewHeight // Error: Binary operator '==' cannot be applied to operands of type 'Dimension' and 'Int'
        view.width == view.superview!.width
    }

    super.updateConstraints()
}

      

It should be simple, put as a Swift newbie atm I don't have any working idea, welcome any help :)

+3


source to share


1 answer


You probably solved this yourself, but for someone else it seems that the == - operator is not overloaded for Int. Therefore, by changing your variable definition to:

let viewHeight: CGFloat = 67

      



will do the trick.

+6


source







All Articles