StackView animation

Is there a way to add view to stackView without animation?

Could you show the code that creates the unwanted animation ?

I tested with a stackView in storyboard. With 2 buttons. When I hide one, the other goes center.

Is it what you call animation ? Do you just want to make it invisible ?

What you could do then, instead of

primaryButton.isHidden = !hasPrimaryButtonTitle

is:

primaryButton.isEnabled = !hasPrimaryButtonTitle

Add in viewDidLoad:

        primaryButton.setTitleColor(stackView.backgroundColor, for: .disabled)

Do the same for the other button.

There's even a simpler way.

primaryButton.alpha = hasPrimaryButtonTitle ? 1.0 : 0
backwardButton.alpha = hasBackwardButtonTitle ? 1.0 : 0

When alpha = 0, button is fully transparent, doesn't even react to tap (just as when disabled).

Nothing to add in viewDidLoad.

StackView animation
 
 
Q