简体   繁体   English

在故事板中创建复杂的布局

[英]creating complex layout in storyboard

I'm trying to create a complex user interface in storyboards. 我正在尝试在故事板中创建复杂的用户界面。 All I get is a bunch of errors and I do not know exactly how to resolve them, because suggested constraints are not appropriate. 我得到的只是一堆错误,我不知道如何解决它们,因为建议的约束是不合适的。 This is link to my project: link . 这是我项目的链接链接 Final layout should look similar to that in an image: 最终布局应该与图像中的布局类似:

在此输入图像描述

Short version: layout should look like the one in the picture on any screen size. 简短版本:布局应该看起来像任何屏幕尺寸的图片中的布局。 Image View and coloured view should both become bigger on bigger screens. 在较大的屏幕上,图像视图和彩色视图都应该变大。 All image view should be the same size. 所有图像视图的大小应相同。

Long version: All image view should be the same size. 长版:所有图像视图的大小应相同。

The big white view will should always take the upper half of screen. 大白视图应始终占据屏幕的上半部分。 I know how to do that. 我知道该怎么做。 The red view should appear exactly in center of its superview,the big white view. 红色视图应该恰好出现在超级视图的中心,即大白视图。

Two blue view should have exactly the same width as the red one. 两个蓝色视图的宽度应与红色视图的宽度完全相同。 Width of those 3 view should match the height of the 2 green views. 这3个视图的宽度应与2个绿色视图的高度相匹配。 Meaning, the taller the screen is(taller screen means higher green views), the wider the space between ImageViews(those who has Image word in it, that basically means wider blue and red views). 意思是,屏幕越高(屏幕越高意味着绿色视图越高),ImageViews之间的空间越大(其中包含Image字的人,基本上意味着更宽的蓝色和红色视图)。

The white views at the left and right fill the space form left image view to left margin and right image view to right margin. 左侧和右侧的白色视图将左侧图像视图的空间填充到左侧边距,右侧图像视图填充到右侧边缘。

All views are pined with 0 to its first neighbour. 所有视图的第一个邻居都为0。 Blue and red are pined horizontally, green views are pined vertically. 蓝色和红色是水平的,绿色的视图是垂直的。 Also the bottom and upper image view are pined to bottom and top of superview(big white view) respectively. 此外,底部和上部图像视图分别被打到superview(大白视图)的底部和顶部。

I do not want to set the height and width constraint on image views, because they should be detremined at runtime. 我不想在图像视图上设置高度和宽度约束,因为它们应该在运行时被解除限制。

I would really appreciate if anyone here could help me out! 如果有人能帮助我,我真的很感激!

I have uploaded the solution on GithubRepo , you can have a look. 我已经在GithubRepo上传了解决方案,你可以看看。

在此输入图像描述

1) "Also the bottom and upper image view are pined to bottom and top of superview(big white view) respectively" this requirement can not be satisfied 1) “底部和上部的图像视图分别是超视图的底部和顶部(大白视图)”这个要求不能满足

2) Spacing on left and right can be decrease/increased by keeping overall requirements satisfied 2)通过保持满足总体要求,可以减少/增加左右间距

多年来我一直在努力解决这个问题,所以我最终决定创建一个视图来管理所有这些调整大小,如HTML页面: ETFlowView

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM