首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在iOS视图控制器中在图像和标签之间添加垂直空间?

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

Stack Overflow用户
提问于 2020-06-05 06:29:01
回答 1查看 134关注 0票数 0

下面是我为我的故事板准备的XAML:

代码语言:javascript
运行
复制
<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>

设计人员创建了一个:

代码语言:javascript
运行
复制
View Controller
   Safe Area
      Stack View
         spash_image.png
         View
         XXX

是否有一种方法可以代替用View来提供图像和标签之间的距离,我可以使用其他的东西。也许在某种程度上增加了垂直约束。

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-06-05 06:43:20

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

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62209395

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档