自动布局:方形图片浏览等宽/高 [英] Auto Layout: Square Image View with equal width / height

查看:148
本文介绍了自动布局:方形图片浏览等宽/高的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

标题似乎有点复杂,所以我就告诉你什么是我想要的一些照片。

The title might seem a bit complicated so I'll just show you what I want in some pictures.

因此​​,这里是我想要的:

So here is what I want:

[1] - http://i.stack.imgur.com/5Vckr.png

这是我想完成它在X code 6:

And here is how I tried to accomplish it in xCode 6:

[2] - http://i.stack.imgur.com/ags9s.png

[3] - http://i.stack.imgur.com/UhIuy.png

正如你可以看到我试图用大小类抓拍的ImageView在纵向视图和横向的底部和顶部的左侧和右侧。
但不知何故,它不是在横向右对齐,如果我看一个iPad的preVIEW的ImageView的显示不出来的。
这大概是pretty简单,但我试过几个小时,仍然没有结果。

As you can see I tried to use size classes to snap the ImageView to the left and right in portrait view and to the bottom and top in landscape. But somehow it is not aligned right in Landscape and if I look at a iPad preview the ImageView does not show up at all. This probably is pretty simple but I tried for hours and still have no result.

感谢您的帮助!

推荐答案

所有的开关模式首先从 W:紧凑型/ H:任何 W:任何/小时:任何
通过这种方式增加约束将应用他们所有的设备和方向。

First of all switch mode from w:Compact/h:Any to w:Any/h:Any. By adding constraints in this mode you will apply them for all devices and orientations.

下面是你需要应用限制的列表:

Here is list of constraints that you need to apply:

与虚线框的两个约束(等宽度和等高度,以上海华)设置较低的优先级(例如750),并让其他人有1000默认的优先级。

Set lower priority (e.g. 750) for the two constraints with the dashed border (Equal Width and Equal Height to superview), and let the others have default priority of 1000.

这篇关于自动布局:方形图片浏览等宽/高的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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