将 StackView 中的可见图像移近前导空间 [英] Move visible images in StackView closer to leading space

查看:31
本文介绍了将 StackView 中的可见图像移近前导空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含在 StackView 中的 20 个(110 * 130 点)UIView 的水平 ScrollView.每个 UIView 包含一个图像.

I have a horizontal ScrollView of 20 (110 * 130 point) UIViews contained within a StackView. Each UIView contains an image.

当某些 UIView 被隐藏时,UIView 的宽度保持在 110 点.但是,隐藏的 UIView 应该留有空格.

When certain UIViews are hidden the UIView width is maintained at 110points. However, spaces are left were the hidden UIView should be.

我一直在练习 3 个 UIView 的 StackView 并隐藏中心 UIView.这在中间留下了一个空间......我希望第 3 个 UIView 移动到第 2 个 UIView 位置(中间)并稍后为后续的 UIView 执行此操作.

I have been practicing with a StackView of 3 UIViews and hiding the center UIView. This leaves a space in the middle... I would like the 3rd UIView to move into the 2nd UIView position (middle) and perform this for subsequent UIViews later on.

有谁知道我该怎么做?这甚至可能吗?

Does anyone know how I could go about doing this? Is this even possible?

我希望使用 UICollectionView 来完成此操作,但是,我认为您无法将图像从 UICollectionView 拖动到 UIView

I was hoping to accomplish this with a UICollectionView, however, I don't think you can drag an image from UICollectionView to UIView

将图像从 UICollectionView 拖放到 UIView?

推荐答案

故事板不适用于这些复杂的用户交互,因此我建议您以编程方式创建堆栈视图,然后也以编程方式设置其约束.这让您可以轻松更改代码中元素的高度.这可能会帮助您入门:以编程方式在 UIStackView 中添加视图

A storyboard isn't meant for these complex user interactions, so I recommend you programmatically create your stack view and then set its constraints programmatically as well. This let's you change elements' heights in your code easily. This might help you get started: Add views in UIStackView programmatically

这篇关于将 StackView 中的可见图像移近前导空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆