自动布局按比例缩放视图 [英] Auto Layout proportionally Scaling Views

查看:187
本文介绍了自动布局按比例缩放视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经找到关于这个话题的几个问题和答案,但我根本无法得到这个工作对我来说。

I have already found several questions and answers about this topic but I simply cannot get this to work for me.

蓝色矩形是包含测试标签和齿轮图像按钮一个UIView。红色的是第二UIView的。

The blue rectangle is a UIView which contains the Test Label and Gear image button. The red one is a second UIView.

我想要做的是让蓝条(这是一个UIView)增加尺寸较大的屏幕尺寸,这将导致在标签和设置按钮的缩放比例,而红色的UIView的高度收缩所以蓝色的UIView可以变得更大。所以基本上,问题是,如何按比例缩放不同的屏幕大小的UIViews。

What I'd like to do is to get the blue bar (which is a UIView) increase in size for larger sized screens, which will result in the scaling of the Label and settings button, while the Red UIView shrink in height so the blue UIView can become larger. So basically the question is, how to proportionally scale the UIViews for different screen sizes.

我一直在使用的宽高比的限制,高度限制(大于/小于)尝试,但我就是不能得到预期的效果。

I have tried using aspect ratio constraints, height constraints (greater than/less than) but I just can't get the desired effect.

感谢。

推荐答案

尝试比例高度和宽度。你需要做的约束平等高地和/或等于宽度的限制,然后你双击,如果你希望做的第一项是在宽度第二个项目的20%和2.0 200%将放大倍数,例如0.2(在宽度是指双)。使其根据您的要求增加或减少比例

Try proportional height and width. You need to make constraints for Equal Heights and/or equal Widths and then you double click on the constraint and change the multiplier for example 0.2 if you wish to make First Item to be 20% of second item in width and 2.0 for 200% (means double) in width. to make it increase or decrease proportionally according to your requirement

这篇关于自动布局按比例缩放视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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