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!
看看这个: https : //developer.apple.com/library/content/documentation/UserExperience/Conceptual/AutolayoutPG/LayoutUsingStackViews.html搜索'Dynamic Stack View',它对我有用
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.