Move visible images in StackView closer to leading space

你。 提交于 2019-12-11 23:46:42

问题


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

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

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?

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

Drag and Drop Image from UICollectionView to UIView?


回答1:


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



来源:https://stackoverflow.com/questions/40659979/move-visible-images-in-stackview-closer-to-leading-space

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!