I am attempting to use the CardTableView, and I am able to render cards from my API call. However, I am trying to load multiple UILabels and lay them out using UIStackViews within the content area of the card. The toolbar and bottom bar already have icons and will be used appropriately.
When I embed the stackView and dont set translatesAutoresizingMaskIntoConstraints = false
the cards are spaced correctly, as shown in this picture:
However there is none of my labels visible. The following picture shows that when i set translatesAutoresizingMaskIntoConstraints = false
the labels show up, but the card spacing is all ruined.
Here is my method for preparing the Content:
private func prepareCardContent() {
contentLabelStackView = UIStackView()
contentLabelStackView.axis = UILayoutConstraintAxis.vertical
contentLabelStackView.distribution = UIStackViewDistribution.equalSpacing
contentLabelStackView.alignment = UIStackViewAlignment.leading
contentLabelStackView.spacing = 0
contentLabelStackView.addArrangedSubview(invitedLabel)
contentLabelStackView.addArrangedSubview(teeUpTitle)
contentLabelStackView.translatesAutoresizingMaskIntoConstraints = false
}
And this is my code for preparing the card itself:
private func preparePresenterCard() {
card.toolbar = toolbar
card.contentView = contentLabelStackView
card.contentViewEdgeInsetsPreset = .vertically5
card.bottomBar = bottomBar
card.depthPreset = .depth3
contentView.addSubview(card)
}
I am unsure what is conflicting with the spacing and layout of the cards with using a nested StackView.
Set a height value to the UIStackView :)