Programmatically Added Constraint Not Working

前端 未结 2 1953
旧时难觅i
旧时难觅i 2021-01-12 08:23

I\'ve been trying to add constraints programmatically to a view that I\'m also adding programmatically to my view controller. However, it seems like the constraints are not

2条回答
  •  无人及你
    2021-01-12 08:38

    set translatesAutoresizingMaskIntoConstraints = false to any view you are settings constraints programatically.

    from the apple doc:
    translatesAutoresizingMaskIntoConstraints

    If you want to use Auto Layout to dynamically calculate the size and position of your view, you must set this property to false, and then provide a non ambiguous, nonconflicting set of constraints for the view.

提交回复
热议问题