根据大小类更改约束的乘数 [英] Changing the multiplier of a constraint based on size class

查看:147
本文介绍了根据大小类更改约束的乘数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能给予约束不同的乘数取决于电流的大小类?

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

我有,我想是在屏幕的常规尺寸宽类的一半大小的景色,我希望它是屏幕大小的80%用于紧凑的尺寸宽度类。在故事板我要补充不同的变量不同尺寸的类来约束恒定值的选项,但不是它的倍频值。这是一个宽度相等约束在相关情况。

I have a view that I want to be half the size of the screen for a regular size class width and I want it to be 80% of the size of the screen for a compact size class width. In the storyboard I have the option to add different variables for different size classes to the constraints constant value, but not it's multiplier value. It's an Equal Widths Constraint in case that is relevant.

我还没有添加约束编程​​所以我希望他们的可能是位于这条道路的解决方案做了很多。谁能告诉我,如果有可能做什么我正在寻找通过故事板或编程?

I haven't done much with adding constraints programatically so I'm hoping their might be a solution that lies down that road. Can anyone tell me if it is possible to do what I'm looking for via storyboard or programatically?

推荐答案

该解决方案是非常明显,不知道我怎么错过了。你必须创建两个不同的约束,启用/禁用相应的他们。

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.

这篇关于根据大小类更改约束的乘数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆