How to change height of UIView that already has height anchor?

前端 未结 5 448

If I have this for a child view controller:

autoCompleteViewController.view.translatesAutoresizingMaskIntoConstraints = false
        NSLayoutConstraint.act         


        
5条回答
  •  南方客
    南方客 (楼主)
    2021-01-13 13:41

    First you have disable the previous constraint and activate another

    For example

    let heightAnchor_one = autoCompleteViewController.view.heightAnchor.constraint(equalToConstant: x)

    let heightAnchor_two = autoCompleteViewController.view.heightAnchor.constraint(equalToConstant: y)

    heightAnchor_one.isActive = true

    heightAnchor_two.isActive = false

    then whichever constraint you need activate that and disable the other.

提交回复
热议问题