问题
How can one programmatically reorder items within a UIStackView in IOS?
(i.e. I can not see a function at https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIStackView_Class_Reference/#//apple_ref/doc/uid/TP40015256-CH1-SW30 to cover this)???
回答1:
surely you can use a combination of
removeArrangedSubview(_:)
insertArrangedSubview(_:atIndex:)
to reorder your views?
回答2:
When adding a view to a parent view, it is automatically removed from it's old parent view.
This is the same with arrangedView
, so you only need to use insertArrangedSubview(_:atIndex:)
and addArrangedSubview()
.
Using removeArrangedSubview()
is not needed.
来源:https://stackoverflow.com/questions/37717460/how-to-programmatically-reorder-items-within-a-uistackview-in-ios