如何在XCODE中水平划分UIView到三个偶数大小的子视图? [英] How to divide UIView in to three even sized subviews horizontally in XCODE?

查看:195
本文介绍了如何在XCODE中水平划分UIView到三个偶数大小的子视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须使用 Xcode UIView 水平划分为三个大小合适的子视图。我试图使用约束。
我得到了以下结果。

I Have to divide a UIView horizontally into three even sized subviews using Xcode. I tried to use constraints. I got the following result.

在某些屏幕尺寸中。在小屏幕电话中,最左侧和最右侧的子视图大小相同。但是,中央子视图在小屏幕中非常小,在大屏幕中非常大。所以,请让我知道将 UIView 水平拆分为三个大小合适的子视图的正确方法。提前致谢。

In some screen sizes. In small screen phones the leftmost and rightmost sub-views are same size. But, the center sub-view is very small in small screens and very large in big screens. So Please let me know the correct way to split the UIView into three even sized sub-views horizontally. Thanks in advance.

注意:我正在使用 Xcode 8.1

推荐答案

设置约束是每个根据开发人员技能和可用性使用的技术。
你将有一天来自己。
这是我用来处理你的情况的方式。

Setting up constraint is technique that every used according to developer skills and usability. You will came with own one day. Here is the way i am using to handle situation like your.

1)在故事板上创建3个宽度相等的视图。(你已经完成了)
2)一起选择所有3个视图。

1)Create 3 views with equal width on storyboard.(You have already Done that) 2)Select all 3 Views together .


  • 添加领先约束(左)

  • 添加顶部约束。

  • 添加高度/底部约束。(根据您的需要/要求)

  • 添加等宽度约束。(必须)

  • Add Leading Constraint(left)
  • Add Top Constraint.
  • Add Height/Bottom Constraint.(According to your needs/requirement)
  • Add Equal width Constraint.(MUST)

这是一张显示上述步骤的图片。

Here is an image showing above step at once.

现在选择上一个视图即。第3个视图(您必须仅选择最后一个视图)

Now Select Last View ie. 3rd View (You must select only Last view)


  • 添加尾随边距约束。 (右)

你现在好了。


  • 高度/底部和顶部约束,你必须根据你的要求添加。

就像我之前说过的那样,请放心使用。

Like i said earlier, go with your convenience.

这篇关于如何在XCODE中水平划分UIView到三个偶数大小的子视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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