Regular / Regular position sizing constraints for all iPads, including iPad pro?

怎甘沉沦 提交于 2019-12-19 07:49:57

问题


I've used multipliers in my constraints, to size my views. However in my constraints for position I've used values, which I change for different sizing classes.

However using regular / regular sizing classes for iPad Pro it's positions values aren't big enough, but for other iPads it's fine.

I seriously don't have to add positioning views with multipliers to provide percentage spaces for all my views as well do I?


回答1:


What we're after is to set the margin between the top of the screen and the top of the subview with relation to the size of the screen. This means the constraint must be related to the superview's height.

Trying to set the distance between the two views (In the traditional sense) is actually a bad idea in this case. Instead, try this.

Add a constraint to center your view vertically in the superview. Now, open up the constraint in the size inspector (The right toolbar).

If you set the multiplier to 0.01 (0 just puts it back in the center of the screen), your view will go past the top of the screen. Change the first item from Center Y to Top. Now your view will be at the top!

From here, you can change the constant to move your view down a fixed amount and change the multiplier to move your view down further proportionally to the screen's height. The formula would look like

subViewYPosition = constant + (superviewHeight * multiplier)

You will need to adjust the constant and multiplier to suit your needs, but I believe this is a good solution to the problem. An example of this is shown below.




回答2:


Right, you don't have to use multipliers because Any value other than 1 creates a proportional constraint. For a Width attribute, for example, the width of the first item can be set to be twice the width of the second item

First thing I like to say that the resolution of ipad and ipad pro have abundant difference so in case of yours to add positioning views I just suggest you to use size class and use of priority, constant and relation (less than or equal, equal, greater than or equal) if necessary.

Hope, It'll helpful for you...



来源:https://stackoverflow.com/questions/33958858/regular-regular-position-sizing-constraints-for-all-ipads-including-ipad-pro

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!