Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cartography set constraint to variable

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 :)

like image 315
Nat Avatar asked Feb 10 '23 18:02

Nat


1 Answers

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.

like image 199
greg Avatar answered Feb 12 '23 08:02

greg