如何在 iOS 视图控制器中的图像和标签之间添加垂直空间

Ala*_*an2 0 ios swift

这是我的故事板的 XAML:

<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="equalCentering" alignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="Zbh-CC-wDS" misplaced="YES">
  <rect key="frame" x="107" y="294" width="200" height="188"/>
  <subviews>
    <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="splash_image.png" translatesAutoresizingMaskIntoConstraints="NO" id="znN-uk-H0B" misplaced="YES">
      <rect key="frame" x="36" y="0.0" width="128" height="80"/>
      <constraints>
        <constraint firstAttribute="height" constant="80" id="A2X-j1-ymP"/>
      </constraints>
    </imageView>
    <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="BWy-bZ-hd4">
      <rect key="frame" x="0.0" y="80" width="200" height="50"/>
        <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
    </view>
    <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" 
      text="ABC" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" 
      id="EcF-nC-k2o" colorLabel="IBBuiltInLabel-Gray">
    <rect key="frame" x="36" y="152" width="128" height="36"/>
      <fontDescription key="fontDescription" type="system" pointSize="30"/>
      <color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
      <nil key="highlightedColor"/>
    </label>
  </subviews>
</stackView>
Run Code Online (Sandbox Code Playgroud)

设计师创造了一个:

View Controller
   Safe Area
      Stack View
         spash_image.png
         View
         XXX
Run Code Online (Sandbox Code Playgroud)

有没有一种方法可以使用其他方法来代替使用视图来提供图像和标签之间的距离。也许以某种方式添加垂直约束。

如果有任何建议,我将不胜感激

Kes*_*Rai 5

选择StackView,您将在属性检查器中看到Spacing选项。将其设置为 10-20 或任何您想要的值。

在此输入图像描述