Greg
Greg

Reputation: 34818

how to programmatically reorder items within a UIStackView in IOS?

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)???

Upvotes: 14

Views: 7939

Answers (2)

Aviel Gross
Aviel Gross

Reputation: 9975

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.

Upvotes: 42

Fonix
Fonix

Reputation: 11597

surely you can use a combination of

removeArrangedSubview(_:)
insertArrangedSubview(_:atIndex:)

to reorder your views?

Upvotes: 16

Related Questions