简体   繁体   English

iOS与WPF带有星号调整的Grid等效吗?

[英]What is the iOS equivalent to WPF's Grid with star sizing?

In WPF, I can create a Grid with multiple column definitions where a single column can occupy the unused screen space with star sizing like so: 在WPF中,我可以创建具有多个列定义的Grid,其中单个列可以使用星形大小来占据未使用的屏幕空间,如下所示:

<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>

在此处输入图片说明

I need to replicate the same UI on iOS. 我需要在iOS上复制相同的UI。 I have looked into using UIStackView, but since I have less experience working with iOS, I'm not sure how to go about doing this. 我已经研究过使用UIStackView,但是由于我对iOS的使用经验较少,因此我不确定该怎么做。 Is UIStackView the right choice or do I need to use another layout? UIStackView是正确的选择还是我需要使用其他布局? How can this UI be replicated on iOS? 如何在iOS上复制此UI? Please note that this needs to be done programmatically. 请注意,这需要以编程方式完成。

Step 1. Drag a "Horizontal UIStackView" to your ViewController in IB, and set the Top, Left, Right and Height constraints. 步骤1.将“ Horizo​​ntal UIStackView”拖到IB中的ViewController中,并设置“顶部”,“左侧”,“右侧”和“高度”约束。

Step2. 第2步。 Drag 5 UIViews in your StackViews, and set "Width" constraint to the 0th, 2nd, 3rd and 4th views. 在您的StackViews中拖动5个UIView,然后将“ Width”约束设置为第0,第2,第3和第4个视图。 So every child view will have a fixed width expect the second one. 因此,每个子视图将具有固定的宽度,而第二个视图则没有。
That's it. 而已。

在此处输入图片说明

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

相关问题 与 MesagingCenter 等效的 iOS 是什么? - What's the iOS equivalent of MesagingCenter? Android等同于iOS的XArbitraryZVertical - What is the Android equivalent of iOS's XArbitraryZVertical 什么是Dropbox iOS应用程序相当于“fb://”? - What is the Dropbox iOS app's equivalent of “fb://”? Android中iOS的权重等于多少 - What is the equivalent of Android's weightsum in iOS iOS相当于Android的startActivityForResult / setResult是什么? - What is the iOS equivalent of Android's startActivityForResult/setResult? iOS与Java / Swing的FlowLayout等效吗? - What is iOS's equivalent of Java/Swing's FlowLayout? 与iOS的委托函数等效的Javascript是什么? - What's Javascript equivalent to iOS's delegate function? 什么是 Android 的 Renderscript 等价于 iOS 和 Windows Phone? - What's the Android's Renderscript equivalent for iOS and Windows Phone? 什么是iOS的等同于Android的colors.xml - What is the iOS equivalent of Android's colors.xml 什么是Android的CordovaPlugin remap等效于iOS Cordova插件的Uri Override - What is the Equivalent of Android's CordovaPlugin remapUri Override for iOS Cordova Plugins
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM