自动布局在故事板,如何设置一个子视图的宽度是它的1/3的SuperView? [英] Autolayout in storyboard, how do I set a width of a subview to be 1/3 of it's superview?

查看:203
本文介绍了自动布局在故事板,如何设置一个子视图的宽度是它的1/3的SuperView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这可能是pretty直线前进,不过,我想弄清楚如何让子视图,它的宽度必须是它的父的宽度的1/3。我想这样做的故事板,而不是在code。所以这种情况是超级简单,只是一个的ViewController的看法里面一个UIView。

I know this might be pretty straight forward, but, I am trying to figure out how to tell a subview that its width needs to be 1/3 of the width of its superview. I want to do this in STORYBOARD, not in code. So the situation is super simple, just a UIView inside of a ViewController's view.

我怎样才能做到这一点使用自动布局在故事板?

How can I accomplish this using Autolayout in storyboard?

推荐答案

首先,在故事板视图树,从子视图到其容器按Ctrl键并选择宽度相等

First, in the storyboard view tree, ctrl-drag from the subview to its container and select "equal widths":

然后,在右边的检查员打开宽度约束,变倍增器,以1/3:

Then, open the width constraint in the inspector on the right, and change "Multiplier" to 1/3:

这篇关于自动布局在故事板,如何设置一个子视图的宽度是它的1/3的SuperView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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