本文介绍了自动布局和比例定位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想,我的情况应该是一个普遍的问题,但我真正的新自动版式,对我似乎特别复杂的:

I suppose that my situation should be a common problem, but I'm really new to AutoLayout and to me it seems particularly complicated:

我想打一个布局很满意,3.5英寸4英寸屏幕。
这是4英寸显示视图:

I want to make a layout to be suitable with 3.5 inches and 4 inches screens.This is the view for 4 inches displays:

和这里是一块3.5英寸显示屏的看法:

And here is the view for a 3.5 inches display:

我需要什么本质上是使分段控制和黄色和蓝色视图比例屏幕尺寸,我想之间的空间。

What I need is essentially make the spaces between the segmented control and the yellow and blue view proportional to the screen size I suppose.

我的解决方案(即不工作):

1)增加对段控制使用小于或等于

1)Adding constraints for top/bottom vertical spaces of the segment control using less or equal to.

2)中添加的限制的其他视图,以保持它们的位置(例如蓝色视图具有底部间距等于零主视图,黄色视图具有固定的顶部间距)。

2)Adding constraints to the other views to keep their positions (for example the blue view has a bottom spacing to the main view equal to zero, the yellow view has a fixed top spacing).

在我的脑海里第1点的约束)只是缩减主视图比例时...但它不会发生......和段景正义之举维护定义为间距等观点背后的的最大值的小于或等于的定义。

In my mind the constraints of point 1) just scale down when the main view scales... but it doesn't happen... and the segment view just move behind the other views maintaining the spacing defined as max value of the "Less then or equal to" definition.

我怎样才能解决这个共同的问题?

How can I solve this common problem?

有我对这种情况创建间隔的看法?在这种情况下,如何你设置呢?

Have I to create spacer views for this situation? and in that case how you'd set up them?

推荐答案

有是一个纯粹的自动版式的解决方案:

There is an pure autolayout solution:


  1. 添加垂直空间的限制[yellowView] - (80 @ 500) - [segmentView]

  2. 添加第二个垂直空间的限制[segmentView] - (> = 5) - [蓝景]

这篇关于自动布局和比例定位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 01:21