简体   繁体   中英

UIStackView inside UIScrollView: how to center-align stack view / items?

I have a UIStackView inside a UIScrollView , and when the width of all items in stack view is less then the width of the scroll view, I want to make the stack view (or the items) to be horizontally centered aligned with the scroll view.

I have the following constraints:

For scrollView: H:|[stackView]| and V:|[stackView]| (so stack view fits with scroll view)

But I can see the stack view seems to shrink to a minimum size that just enough for all its arranged subviews' intrinsic content size, and it's left aligned to the scroll view.

Is there anyway to make it horizontally-centred in the scroll view?

Thanks!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM