I am working on the Implementing A Custom Control iOS tutorial (I would link it but I'm not allowed to use more than two links).
I am at the point where I have 5 buttons generate within a StackView. I implemented these constraints for each button:
button.translatesAutoresizingMaskIntoConstraints = false
button.heightAnchor.constraint(equalToConstant: 44.0).isActive = true
button.widthAnchor.constraint(equalToConstant: 44.0).isActive = true
I entered all code exactly as specified, but when I run the app, the buttons fill the stack view vertically and horizontally:
If I set the StackView's alignment property to Top, I can prevent the buttons from stretching vertically, but the last button is still stretched horizontally:
I have tried many different methods for preventing the last button being stretched to no avail. In the console, I see that the size constraints are being overridden, but I cannot figure out by what.
I would like these buttons to maintain the specified height and width (44) within the StackView. Any ideas on how to do this? I can give more info if needed.