gpt4 book ai didi

ios - 堆栈 View 和排列 View 属性

转载 作者:行者123 更新时间:2023-11-29 00:29:42 25 4
gpt4 key购买 nike

关于堆栈 View 的排列 View ,我想不出一件事。

假设我有一个包含三个按钮的堆栈 View 。在将这些按钮添加到堆栈 View 的排列 subview 之前,是否必须将这些按钮添加为 UIViewControllersubviews

最佳答案

这在UIStackView reference中得到了回答.我强调了以下摘录的相关部分:

Maintaining Consistency Between the Arranged Views and Subviews

The stack view ensures that its arrangedSubviews property is always a subset of its subviews property. Specifically, the stack view enforces the following rules:

  • When the stack view adds a view to its arrangedSubviews array, it also adds that view as a subview, if it isn’t already.
  • When a subview is removed from the stack view, the stack view also removes it from the arrangedSubviews array.
  • Removing a view from the arrangedSubviews array does not remove it as a subview. The stack view no longer manages the view’s size and position, but the view is still part of the view hierarchy, and is rendered on screen if it is visible.

Although the arrangedSubviews array always contains a subset of the subviews array, the order of these arrays remain independent.

  • The order of the arrangedSubviews array defines the order in which views appear in the stack. For horizontal stacks, the views are laid out in reading order, with the lower index views appearing before the higher index views. In English, for example, the views are laid out in order from left to right. For vertical stacks, the views are laid out from top to bottom, with the lower index views above the higher index views.
  • The order of the subviews array defines the Z-order of the subviews. If the views overlap, subviews with a lower index appear behind subviews with a higher index.

关于ios - 堆栈 View 和排列 View 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42208249/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com