UIImageView/UIView 的自动布局纵横比 [英] Autolayout aspect ratio for UIImageView / UIView

查看:23
本文介绍了UIImageView/UIView 的自动布局纵横比的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何为 UIImageView/UIView 设置自动布局,以便 iphone 6 和 6 plus 的图像视图宽度和高度增加一点.我曾尝试添加约束纵横比,但增加的高度和宽度非常大.无论如何设置图像视图的约束高度和宽度可以为iphone 6和6 plus手动设置.看看屏幕截图,iphone 6 和 6 plus 中的图像视图应该比现在显示的要小一点.

How to set autolayout for UIImageView /UIView so that the image view width and height increases a bit for iphone 6 and 6 plus. I have tried adding the constraint Aspect ratio but the increased height and width are very big. Is there anyway to set the constraint height and width of image view can be set manually for iphone 6 and 6 plus. Take a look at the screenshot the image view in iphone 6 and 6 plus should be little smaller than it is showing now.

推荐答案

据我所知,您的问题是您想要控制在每个不同的屏幕尺寸下图像的增加量.你可以控制一切.您需要做的是在您的图像上分配一个等宽约束.最好是图像的宽度.关系将与超级视图相关,然后您可以通过添加自己的乘数来更改关系.

As I understood your problem is that you want to control how much the image will be increased in each different screen size. You can control everything. What you need to do is to assign an equals width constraint on your image. Preferable on image's width. The relation will be with the superview and then you can change the relation by adding your own Multiplier.

你需要做什么:

1) 选择您的图像视图.

1) Select your image view.

2) 按住控制键.按住它的同时,将鼠标从图像视图拖到外部视图.

2) Hold down the control key. While you are holding it, drag your mouse from the image view to the outer view.

3) 选择等于宽度".

3) Select 'Equals width'.

4) 在约束"选项卡中双击您的约束.

4) Double click on your constraint in the 'Constraints' tab.

5) 确保图像视图显示为第一项,如果不是,请单击第一项并选择反转第一项和第二项".

5) Ensure that the image view is presented as the first item, if not click on the first item and select 'Reverse first and second item'.

6) 使用乘数进行游戏,直到您对预览屏幕上的结果感到满意为止.

6) Play with the multiplier until you are satisfied with the result on the preview screen.

这篇关于UIImageView/UIView 的自动布局纵横比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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