1. <small id='KPuDI'></small><noframes id='KPuDI'>

      2. <legend id='KPuDI'><style id='KPuDI'><dir id='KPuDI'><q id='KPuDI'></q></dir></style></legend>

        <i id='KPuDI'><tr id='KPuDI'><dt id='KPuDI'><q id='KPuDI'><span id='KPuDI'><b id='KPuDI'><form id='KPuDI'><ins id='KPuDI'></ins><ul id='KPuDI'></ul><sub id='KPuDI'></sub></form><legend id='KPuDI'></legend><bdo id='KPuDI'><pre id='KPuDI'><center id='KPuDI'></center></pre></bdo></b><th id='KPuDI'></th></span></q></dt></tr></i><div id='KPuDI'><tfoot id='KPuDI'></tfoot><dl id='KPuDI'><fieldset id='KPuDI'></fieldset></dl></div>
          <bdo id='KPuDI'></bdo><ul id='KPuDI'></ul>

        <tfoot id='KPuDI'></tfoot>

        如何使用自动布局来缩放所有屏幕尺寸的视图?

        How to use autolayout to scale view for all screen sizes?(如何使用自动布局来缩放所有屏幕尺寸的视图?)

                <tfoot id='CWZei'></tfoot>

                <small id='CWZei'></small><noframes id='CWZei'>

              • <i id='CWZei'><tr id='CWZei'><dt id='CWZei'><q id='CWZei'><span id='CWZei'><b id='CWZei'><form id='CWZei'><ins id='CWZei'></ins><ul id='CWZei'></ul><sub id='CWZei'></sub></form><legend id='CWZei'></legend><bdo id='CWZei'><pre id='CWZei'><center id='CWZei'></center></pre></bdo></b><th id='CWZei'></th></span></q></dt></tr></i><div id='CWZei'><tfoot id='CWZei'></tfoot><dl id='CWZei'><fieldset id='CWZei'></fieldset></dl></div>
                  <tbody id='CWZei'></tbody>
                  <bdo id='CWZei'></bdo><ul id='CWZei'></ul>

                  <legend id='CWZei'><style id='CWZei'><dir id='CWZei'><q id='CWZei'></q></dir></style></legend>
                  本文介绍了如何使用自动布局来缩放所有屏幕尺寸的视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我的应用程序的主导航视图使用带有背景图像的 UIButtons.我在 IB 中使用自动布局来布局视图.

                  The main navigation view of my app uses UIButtons with background images. I'm using autolayout in IB to lay out the view.

                  我希望 iphone 4、5、6 和 6plus 上的视图看起来相同(或相似,只是适当缩放).我尝试过使用垂直和水平约束,但无法弄清楚如何使用纵横比约束.

                  I want the view to look the same (or similar, just scaled appropriately) on iphone 4, 5, 6, and 6plus. I have tried using vertical and horizontal constraints but have trouble figuring out how to use the aspect ratio constraint.

                  这是 iphone 5 上的视图.

                  This is what the view looks like on an iphone 5.

                  这是我目前在 iphone 6 上得到的结果

                  Here is what I've got so far on an iphone 6

                  这就是我希望它在 iphone 6/6plus 上的样子.

                  This is what I want it to look like on an iphone 6/6plus.

                  如何使用自动布局来缩放视图,使其在所有 iphone 屏幕尺寸下看起来都相同或相似?

                  How do I use autolayout to scale the view so that it looks the same or similar for all iphone screen sizes?

                  推荐答案

                  我做了一些修改,我相信我已经找到了解决方案.我将演示如何为您视图中间的两个较大的正方形执行此操作.

                  I've done some tinkering and I believe I've found a solution. I will demonstrate how to do it for the two larger squares roughly in the middle of your view.

                  这是一张参考图:

                  首先,您需要创建一个容器(我的蓝色视图),它跨越了父视图的整个宽度,并且高度等于或大于您的内部正方形(橙色).
                  此视图需要以下约束:将 Center X 与 Superview 对齐,将 Center Y 与 Superview 对齐(OR 约束为其提供所需的 Y 位置),Height Equals: [square height],Trailing Space to Superview, 引领空间到 Superview.

                  First, you need to create a container (my blue view) that spans the entire width of the superview, and has a height the same or larger than your inner squares (orange).
                  This view needs the following constraints: Align Center X to Superview, Align Center Y to Superview (OR constraints to give it the Y position you desire), Height Equals: [square height], Trailing Space to Superview, Leading Space to Superview.

                  内部的橙色方块必须放在容器内,并且必须给出以下约束:Align Center X to Superview,Leading Space to Superview(值=正方形和superview边缘之间的空间), Trailing 到 [其他视图] 的空间(值 = 方块之间的空间).一起选择两个正方形,并添加纵横比、等宽和等高约束.
                  粗体中的项目取决于您选择的方格.左边应该有前导空间到超级视图和尾随空间到另一个视图,右边应该交换这些约束.

                  The inner orange squares must be placed inside the container, and must be given the following constraints: Align Center X to Superview, Leading Space to Superview (value = space between square and edge of superview), Trailing Space to [other view] (value = space between squares). Select the two squares together, and add Aspect Ratio, Equal Width and Equal Height constraints.
                  The items in bold depend on which square you're selecting. The left one should have leading space to superview and trailing space to the other view, and the right one should have these constraints swapped.

                  这应该会给你你想要的自动布局效果.

                  This should give you your desired effect with autolayout.

                  这篇关于如何使用自动布局来缩放所有屏幕尺寸的视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  iOS AutoLayout - get frame size width(iOS AutoLayout - 获取帧大小宽度)
                  Auto layout constraints issue on iOS7 in UITableViewCell(UITableViewCell中iOS7上的自动布局约束问题)
                  How to resize superview to fit all subviews with autolayout?(如何调整超级视图的大小以适应所有具有自动布局的子视图?)
                  Springs in Auto Layout: Distribute views evenly, with constraints, in Xcode 5(自动布局中的弹簧:在 Xcode 5 中使用约束均匀分布视图)
                  reloadData() of UITableView with Dynamic cell heights causes jumpy scrolling(具有动态单元格高度的 UITableView 的 reloadData() 导致跳跃滚动)
                  What is NSLayoutConstraint quot;UIView-Encapsulated-Layout-Heightquot; and how should I go about forcing it to recalculate cleanly?(什么是 NSLayoutConstraint“UIView-Encapsulated-Layout-Height?我应该如何强制它干净地重新计算?) - IT屋-程序员

                    <small id='wLB90'></small><noframes id='wLB90'>

                    <i id='wLB90'><tr id='wLB90'><dt id='wLB90'><q id='wLB90'><span id='wLB90'><b id='wLB90'><form id='wLB90'><ins id='wLB90'></ins><ul id='wLB90'></ul><sub id='wLB90'></sub></form><legend id='wLB90'></legend><bdo id='wLB90'><pre id='wLB90'><center id='wLB90'></center></pre></bdo></b><th id='wLB90'></th></span></q></dt></tr></i><div id='wLB90'><tfoot id='wLB90'></tfoot><dl id='wLB90'><fieldset id='wLB90'></fieldset></dl></div>
                          <tbody id='wLB90'></tbody>

                          <tfoot id='wLB90'></tfoot>
                        1. <legend id='wLB90'><style id='wLB90'><dir id='wLB90'><q id='wLB90'></q></dir></style></legend>
                          • <bdo id='wLB90'></bdo><ul id='wLB90'></ul>