使用iOS 6的自动布局相对视图位置的上海华的大小 [英] Using iOS 6 Auto Layout to position view relative to size of superview

查看:123
本文介绍了使用iOS 6的自动布局相对视图位置的上海华的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望有相对上海华而不是绝对的大小定位对象。

I wish to have objects positioned relative to the size of the superview instead of absolutely.

例如,我不想说一个元素是从顶部50像素,我想说的是。

For example, I do not want to say that an element is "50px from the top", I want to say it is "1/3 of the way down".

有没有办法做到这一点使用自动布局?如果没有,什么是最好的方式?

Is there any way to do this using auto layout? If not, what is the best way?

干杯

推荐答案

插座添加到superivew的高度约束和出口限制的topspace。在code topspace约束的常数设置为等于0.33的数值*上海华的高度约束。

Add an Outlet to the height constraint of superivew and an outlet constraint to the topspace. In code set the constant of topspace constraint to a value equal to 0.33 * height constraint of superview.

这篇关于使用iOS 6的自动布局相对视图位置的上海华的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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