简体   繁体   English

iOS Swift嵌套垂直StackView

[英]IOS Swift nested vertical StackView

Is it a good practice to have nested vertical or horizontal StackViews in my project there is requirement to do so or is there any other way to avoid this or it is okay to use nested vertical StackViews. 在我的项目中嵌套垂直或水平StackView是一种好习惯,还是有必要这样做,或者是否有其他方法可以避免这种情况,或者可以使用嵌套垂直StackView。

Storyboard looks like below it is working fine and UI is appearing as expected across resolution but not sure if it is good practice or not 情节提要板看起来像下面一样,工作正常,并且UI在整个分辨率下均按预期方式显示,但不确定这是否是一种好的做法

在此处输入图片说明

As always there are Pros and Cons. 一如既往地有优点和缺点。

Pro: 优点:

  • Layout structure is easily comprehensive 布局结构易于综合
  • You can hide/show groups of views very easily 您可以非常轻松地隐藏/显示视图组
  • Saves time towards doing all things with constraints 节省了在约束下做所有事情的时间
  • Reordering is a lot easier 重新排序要容易得多

Con: 缺点:

So you have to decide or test in your own situation, if you notice any performance issues. 因此,如果您发现任何性能问题,则必须根据自己的情况决定或测试。 Maybe use an older device like iPhone 6 or so and try to open your view controller that contains this layout and check if it lags or so. 也许使用较旧的设备(例如iPhone 6左右),尝试打开包含此布局的视图控制器,并检查其是否滞后。

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

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