Changing the multiplier of a constraint based on size class

后端 未结 2 1465
忘掉有多难
忘掉有多难 2021-02-20 08:59

Is it possible to give a constraint a different multiplier depending on the current size class?

I have a view that I want to be half the size of the screen for a regular

2条回答
  •  日久生厌
    2021-02-20 09:30

    The solution was painfully obvious, no idea how I missed it. You have to create two different constraints and enable/disable them accordingly.

    I think this is a very inelegant solution tho, I would really like if apple would make it so that you can define different multipliers per size class just like the constant variable. Having lots of constraints that only differ by one value seems like it could result in a very unwieldy and hard to maintain storyboard.

    If anybody knows of any better solutions, or knows why it is done this way I would still like to hear it.

提交回复
热议问题