什么是相当于WPF的Grid与星大小的iOS?

问题描述 投票:0回答:1

在WPF中,我可以创建一个具有多个列定义的网格,其中单个列可以占用未使用的屏幕空间,如下所示:

<Grid Height="50">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="50"/>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="50"/>
        <ColumnDefinition Width="50"/>
        <ColumnDefinition Width="50"/>
    </Grid.ColumnDefinitions>

    <Grid Grid.Column="0" Background="Red"/>
    <Grid Grid.Column="1" Background="Blue"/>
    <Grid Grid.Column="2" Background="Yellow"/>
    <Grid Grid.Column="3" Background="Pink"/>
    <Grid Grid.Column="4" Background="Green"/>
</Grid>

enter image description here

我需要在iOS上复制相同的UI。我已经研究过使用UIStackView,但由于我使用iOS的经验较少,我不知道如何去做。 UIStackView是正确的选择还是需要使用其他布局?如何在iOS上复制此UI?请注意,这需要以编程方式完成。

ios wpf grid uistackview
1个回答
0
投票

步骤1.将“Horizo​​ntal UIStackView”拖动到IB中的ViewController,并设置Top,Left,Right和Height约束。

第2步。在StackViews中拖动5个UIViews,并将“宽度”约束设置为第0,第2,第3和第4个视图。所以每个子视图都有一个固定的宽度,期望第二个。 而已。

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.