Cartography set constraint to variable

806 views Asked by At

I have no idea how to set constrant.height to 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()
}

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

1

There are 1 answers

1
greg On BEST ANSWER

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

let viewHeight: CGFloat = 67

will do the trick.