所以我正在尝试为应用程序制作启动屏幕。启动屏幕由 2 个文本框和 2 个 UIImageView 组成。
我的问题是我无法让自动布局与屏幕的百分比一起使用,而是有这些数字,我不太知道该怎么处理。因此,虽然我知道这两个 ImageView 是距离边缘的屏幕宽度的四分之一,但我不知道如何表达它们。另外我不知道如何使图像大小在所有设备上占据相同的空间比例。
您能帮我开始设置吗?
最佳答案
自动布局不支持百分比,但支持宽高比。
block 引用>
- you need to add one view and add your two imageViews and textFields add equal width and height constraint for ImageViews and same for TextField
you can also add constraints to ImageView to expand in rest of space for that just add margin constraints and equal width and Height of ImageViews.
- 根据您的要求将宽高比添加到 ImageView 的宽度和 SuperViews 的宽度。
you can add aspect Ratio with individually to width and Height. here as you mentioned in que. you can add aspect ration 4:1 for 4th of the screen size.
- 对文本字段执行相同的操作。
如果您仍然需要帮助,请告诉我,我可以通过屏幕截图进行深入解释。
关于ios - 如何使用自动布局将内容按屏幕尺寸的百分比 IOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32389435/