是否必须使用autolayout才能使用stackview
Is it necessary to use autolayout to use stackview
是否有必要强制使用autolayout来只使用stackview
假设我在没有自动布局的情况下完成了整个项目,
现在对于特定的屏幕,我必须使用 Stackview 来平均划分视图内的标签数量。
有什么解决办法吗..
问题
实际上我必须自定义一个没有自动布局的旧项目,现在我只需要修改一个屏幕,它不需要任何约束,只需要像 uitablecell 一样的堆栈视图,每个单元格中有 8 个标签。
I know we can do it by just calculating frame run time but is there is
any other way to do it.
堆栈视图使用自动布局来定位和调整其排列视图的大小。
尽管堆栈视图允许您在不直接使用自动布局的情况下对其内容进行布局,但您仍然需要使用自动布局来定位堆栈视图本身。通常,这意味着固定堆栈视图的至少两个相邻边缘以定义其位置。在没有额外约束的情况下,系统会根据其内容计算堆栈视图的大小。
是的,有必要使用自动布局来定位堆栈视图本身
Although a stack view allows you to layout its contents without using
Auto Layout directly, you still need to use Auto Layout to position
the stack view, itself
如果你设置stack view的translatesAutoresizingMaskIntoConstraints
属性为true
,那么你可以设置stack view的frame
和autoresizingMask
来控制大小和堆栈视图的位置。自动布局会自动将您的设置转化为约束条件。
堆栈视图的排列子视图必须而不是将translatesAutoresizingMaskIntoConstraints
设置为true
。
是否有必要强制使用autolayout来只使用stackview 假设我在没有自动布局的情况下完成了整个项目, 现在对于特定的屏幕,我必须使用 Stackview 来平均划分视图内的标签数量。 有什么解决办法吗..
问题
实际上我必须自定义一个没有自动布局的旧项目,现在我只需要修改一个屏幕,它不需要任何约束,只需要像 uitablecell 一样的堆栈视图,每个单元格中有 8 个标签。
I know we can do it by just calculating frame run time but is there is any other way to do it.
堆栈视图使用自动布局来定位和调整其排列视图的大小。 尽管堆栈视图允许您在不直接使用自动布局的情况下对其内容进行布局,但您仍然需要使用自动布局来定位堆栈视图本身。通常,这意味着固定堆栈视图的至少两个相邻边缘以定义其位置。在没有额外约束的情况下,系统会根据其内容计算堆栈视图的大小。
是的,有必要使用自动布局来定位堆栈视图本身
Although a stack view allows you to layout its contents without using Auto Layout directly, you still need to use Auto Layout to position the stack view, itself
如果你设置stack view的translatesAutoresizingMaskIntoConstraints
属性为true
,那么你可以设置stack view的frame
和autoresizingMask
来控制大小和堆栈视图的位置。自动布局会自动将您的设置转化为约束条件。
堆栈视图的排列子视图必须而不是将translatesAutoresizingMaskIntoConstraints
设置为true
。