Where to update Autolayout constraints when size changes?

前端 未结 2 480
庸人自扰
庸人自扰 2020-12-19 03:58

I have several UIViews laid out along the bottom of a containing UIView. I want these views to always be equal width, and always stretch to collect

2条回答
  •  离开以前
    2020-12-19 04:34

    There is no reason to update the width manually:

    1. Place all the views with equal width in your view with no spacing in between each other
    2. Add an equal width constraint to all of them
    3. Add constraints with 0 width for spacing between sides and each other
    4. Lower the priority of one or more of the equal width constraints just in case the width cannot be divided equally.

    Then auto layout will handle everything for you.

提交回复
热议问题